diff --git a/composer.json b/composer.json index e0315eb..9630942 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ringcentral/psr7": "^1.2" }, "require-dev": { - "phpunit/phpunit": "^7.0 || ^5.0 || ^4.8", + "phpunit/phpunit": "^9.0 || ^7.0 || ^5.0 || ^4.8", "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3", "clue/block-react": "^1.1" } diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index b145410..f6102fd 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -54,5 +54,19 @@ protected function createCallableMock() { return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); } + + public function setExpectedException($exception, $message = '', $code = 0) + { + if (method_exists($this, 'expectException')) { + $this->expectException($exception); + if ($message !== '') { + $this->expectExceptionMessage($message); + } + $this->expectExceptionCode($code); + } else { + parent::setExpectedException($exception, $message, $code); + } + } + } diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index f0b0a88..4cf1101 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -16,7 +16,10 @@ class FunctionalTest extends AbstractTestCase private $tcpConnector; private $dnsConnector; - public function setUp() + /** + * @before + */ + public function setUpConnector() { $this->loop = Factory::create(); diff --git a/tests/ProxyConnectorTest.php b/tests/ProxyConnectorTest.php index f6f6276..1ae2f09 100644 --- a/tests/ProxyConnectorTest.php +++ b/tests/ProxyConnectorTest.php @@ -11,32 +11,29 @@ class ProxyConnectorTest extends AbstractTestCase { private $connector; - public function setUp() + /** + * @before + */ + public function setUpMock() { $this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock(); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidProxy() { + $this->setExpectedException('InvalidArgumentException'); new ProxyConnector('///', $this->connector); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidProxyScheme() { + $this->setExpectedException('InvalidArgumentException'); new ProxyConnector('ftp://example.com', $this->connector); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidHttpsUnixScheme() { + $this->setExpectedException('InvalidArgumentException'); new ProxyConnector('https+unix:///tmp/proxy.sock', $this->connector); }