Skip to content

Commit bab7ee9

Browse files
authored
Merge pull request php-curl-class#519 from zachborboa/master
Fix failure tests erroring with mismatching error codes
2 parents 3a6f673 + 90f4552 commit bab7ee9

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

tests/PHPCurlClass/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Test
88
{
99
const TEST_URL = 'http://127.0.0.1:8000/';
10-
const ERROR_URL = 'https://1.2.3.4/';
10+
const ERROR_URL = 'http://1.2.3.4/';
1111

1212
public function __construct()
1313
{

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,12 +1103,12 @@ public function testTimeout()
11031103
public function testError()
11041104
{
11051105
$test = new Test();
1106-
$test->curl->setOpt(CURLOPT_CONNECTTIMEOUT_MS, 4000);
11071106
$test->curl->get(Test::ERROR_URL);
11081107
$this->assertTrue($test->curl->error);
11091108
$this->assertTrue($test->curl->curlError);
1110-
$this->assertEquals(CURLE_OPERATION_TIMEOUTED, $test->curl->errorCode);
1111-
$this->assertEquals(CURLE_OPERATION_TIMEOUTED, $test->curl->curlErrorCode);
1109+
$possible_errors = array(CURLE_SEND_ERROR, CURLE_OPERATION_TIMEOUTED);
1110+
$this->assertTrue(in_array($test->curl->errorCode, $possible_errors, true));
1111+
$this->assertTrue(in_array($test->curl->curlErrorCode, $possible_errors, true));
11121112
}
11131113

11141114
public function testErrorMessage()

tests/PHPCurlClass/PHPMultiCurlClassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,9 @@ public function testMultiCurlCallbackError()
601601
\PHPUnit\Framework\Assert::assertTrue($instance->error);
602602
\PHPUnit\Framework\Assert::assertTrue($instance->curlError);
603603
\PHPUnit\Framework\Assert::assertFalse($instance->httpError);
604-
\PHPUnit\Framework\Assert::assertEquals(CURLE_OPERATION_TIMEOUTED, $instance->errorCode);
605-
\PHPUnit\Framework\Assert::assertEquals(CURLE_OPERATION_TIMEOUTED, $instance->curlErrorCode);
604+
$possible_errors = array(CURLE_SEND_ERROR, CURLE_OPERATION_TIMEOUTED);
605+
\PHPUnit\Framework\Assert::assertTrue(in_array($instance->errorCode, $possible_errors, true));
606+
\PHPUnit\Framework\Assert::assertTrue(in_array($instance->curlErrorCode, $possible_errors, true));
606607
});
607608

608609
$multi_curl->addDelete(Test::ERROR_URL);

0 commit comments

Comments
 (0)