Skip to content

Commit 4b5223f

Browse files
authored
Merge pull request #34 from SimonFrings/tests
Run test on PHPUnit 9
2 parents 3f75c88 + 7dd6226 commit 4b5223f

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"ringcentral/psr7": "^1.2"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^7.0 || ^5.0 || ^4.8",
26+
"phpunit/phpunit": "^9.0 || ^7.0 || ^5.0 || ^4.8",
2727
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
2828
"clue/block-react": "^1.1"
2929
}

tests/AbstractTestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,19 @@ protected function createCallableMock()
5454
{
5555
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
5656
}
57+
58+
public function setExpectedException($exception, $message = '', $code = 0)
59+
{
60+
if (method_exists($this, 'expectException')) {
61+
$this->expectException($exception);
62+
if ($message !== '') {
63+
$this->expectExceptionMessage($message);
64+
}
65+
$this->expectExceptionCode($code);
66+
} else {
67+
parent::setExpectedException($exception, $message, $code);
68+
}
69+
}
70+
5771
}
5872

tests/FunctionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class FunctionalTest extends AbstractTestCase
1616
private $tcpConnector;
1717
private $dnsConnector;
1818

19-
public function setUp()
19+
/**
20+
* @before
21+
*/
22+
public function setUpConnector()
2023
{
2124
$this->loop = Factory::create();
2225

tests/ProxyConnectorTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,29 @@ class ProxyConnectorTest extends AbstractTestCase
1111
{
1212
private $connector;
1313

14-
public function setUp()
14+
/**
15+
* @before
16+
*/
17+
public function setUpMock()
1518
{
1619
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
1720
}
1821

19-
/**
20-
* @expectedException InvalidArgumentException
21-
*/
2222
public function testInvalidProxy()
2323
{
24+
$this->setExpectedException('InvalidArgumentException');
2425
new ProxyConnector('///', $this->connector);
2526
}
2627

27-
/**
28-
* @expectedException InvalidArgumentException
29-
*/
3028
public function testInvalidProxyScheme()
3129
{
30+
$this->setExpectedException('InvalidArgumentException');
3231
new ProxyConnector('ftp://example.com', $this->connector);
3332
}
3433

35-
/**
36-
* @expectedException InvalidArgumentException
37-
*/
3834
public function testInvalidHttpsUnixScheme()
3935
{
36+
$this->setExpectedException('InvalidArgumentException');
4037
new ProxyConnector('https+unix:///tmp/proxy.sock', $this->connector);
4138
}
4239

0 commit comments

Comments
 (0)