Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit e434e75

Browse files
committed
Attempt to fix several failing unit tests
- Exception types vary between versions of the php ampq library. - A bad conditional in guzzle3 logic may cause problems.
1 parent a09ed00 commit e434e75

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/Check/GuzzleHttpService.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace ZendDiagnostics\Check;
99

10+
use InvalidArgumentException;
1011
use Guzzle\Http\Client as Guzzle3Client;
1112
use Guzzle\Http\ClientInterface as Guzzle3ClientInterface;
1213
use GuzzleHttp\Client as Guzzle456Client;
@@ -58,7 +59,7 @@ public function __construct(
5859
}
5960

6061
if ((! $guzzle instanceof Guzzle3ClientInterface) && (! $guzzle instanceof Guzzle456ClientInterface)) {
61-
throw new \InvalidArgumentException(
62+
throw new InvalidArgumentException(
6263
'Parameter "guzzle" must be an instance of "\Guzzle\Http\ClientInterface"'
6364
. ' or "\GuzzleHttp\ClientInterface"'
6465
);
@@ -84,15 +85,17 @@ public function check()
8485
*/
8586
private function guzzle3Check()
8687
{
87-
$response = $this->guzzle->createRequest(
88-
$this->method,
89-
$this->url,
90-
$this->headers,
91-
$this->body,
92-
array_merge(['exceptions' => false], $this->options)
93-
)->send();
94-
95-
if ($this->statusCode !== $statusCode = $response->getStatusCode()) {
88+
$response = $this->guzzle
89+
->createRequest(
90+
$this->method,
91+
$this->url,
92+
$this->headers,
93+
$this->body,
94+
array_merge(['exceptions' => false], $this->options)
95+
)
96+
->send();
97+
98+
if ($this->statusCode !== ($statusCode = $response->getStatusCode())) {
9699
return $this->createStatusCodeFailure($statusCode);
97100
}
98101

test/ChecksTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public function testRabbitMQ()
6666
$this->assertInstanceOf(Success::class, $result);
6767

6868
$check = new RabbitMQ('127.0.0.250', 9999);
69-
$this->expectException(ErrorException::class);
69+
// Exception type varies between different versions of php-amqplib;
70+
// sometimes it is a descendent of ErrorException, sometimes
71+
// RuntimeException. As such, catching any exception here.
72+
$this->expectException(Exception::class);
7073
$check->check();
7174
}
7275

0 commit comments

Comments
 (0)