Skip to content

Commit

Permalink
Add test for response empty case
Browse files Browse the repository at this point in the history
  • Loading branch information
usox committed Sep 25, 2022
1 parent 34a98fc commit fcf7fa0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"require": {
"ext-curl": "*",
"php": ">=7.3",
"php": "^7.3||^8",
"php-curl-class/php-curl-class": "^8.6"
},
"require-dev": {
Expand Down
24 changes: 24 additions & 0 deletions tests/IpIntel/IpIntelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,28 @@ public function testValidateThrowsExceptionOnServiceError(): void

$this->ipIntel->validate($ip, 0.2);
}

public function testValidateThrowsExceptionOnEmptyResponse(): void
{
$this->expectException(ServiceException::class);

$ip = '666.42.33.21';

$this->curl->shouldReceive('setTimeout')
->with(5)
->once();

$this->curl->shouldReceive('get')
->with(
'https://check.getipintel.net/check.php',
[
'ip' => $ip,
'contact' => $this->contactEmailAddress
]
)
->once()
->andReturnNull();

$this->ipIntel->validate($ip, 0.2);
}
}

0 comments on commit fcf7fa0

Please sign in to comment.