Skip to content

Commit

Permalink
added pattern null check, update docs, add test (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK authored Oct 28, 2024
1 parent 86ae5b2 commit f912e98
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ $filter
->setPattern(234)
->setSearchPattern(\Vonage\Numbers\Filter\OwnedNumbers::SEARCH_PATTERN_CONTAINS)
;
$response = $client->numbers()->searchOwned($filter);
$response = $client->numbers()->searchOwned(null, $filter);
```

`has_application`:
Expand Down
2 changes: 1 addition & 1 deletion src/Numbers/Filter/OwnedNumbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OwnedNumbers implements FilterInterface

protected int $pageIndex = 1;

protected string $pattern;
protected ?string $pattern = null;

protected int $searchPattern = 0;

Expand Down
21 changes: 21 additions & 0 deletions test/Numbers/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,27 @@ public function testPurchaseNumberWithNumberObject(): void
// If there's no exception thrown, everything is fine!
}

public function testSearchOwnedNumbersWithFilter(): void
{
$this->vonageClient->send(Argument::that(function (RequestInterface $request) {
$uri = $request->getUri();
$uriString = $uri->__toString();
$this->assertEquals(
'https://rest.nexmo.com/account/numbers?size=10&index=1&application_id=66c04cea-68b2-45e4-9061-3fd847d627b8&page_index=1',
$uriString
);

$this->assertEquals('GET', $request->getMethod());

return true;
}))->willReturn($this->getResponse('owned-numbers'));

$filter = new \Vonage\Numbers\Filter\OwnedNumbers();
$filter->setApplicationId("66c04cea-68b2-45e4-9061-3fd847d627b8");

$response = $this->numberClient->searchOwned(null, $filter);
}

public function testPurchaseNumberWithNumberAndCountry(): void
{
// When providing a number string, the first thing that happens is a GET request to fetch number details
Expand Down
16 changes: 16 additions & 0 deletions test/Numbers/responses/owned-numbers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"count": 1234,
"numbers": [
{
"country": "GB",
"msisdn": "447700900000",
"type": "mobile-lvn",
"cost": "1.25",
"features": [
"VOICE",
"SMS",
"MMS"
]
}
]
}

0 comments on commit f912e98

Please sign in to comment.