Skip to content

Commit

Permalink
Merge pull request #34 from SimonFrings/tests
Browse files Browse the repository at this point in the history
Run test on PHPUnit 9
  • Loading branch information
clue authored Jun 19, 2020
2 parents 3f75c88 + 7dd6226 commit 4b5223f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
14 changes: 14 additions & 0 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}

5 changes: 4 additions & 1 deletion tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class FunctionalTest extends AbstractTestCase
private $tcpConnector;
private $dnsConnector;

public function setUp()
/**
* @before
*/
public function setUpConnector()
{
$this->loop = Factory::create();

Expand Down
17 changes: 7 additions & 10 deletions tests/ProxyConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 4b5223f

Please sign in to comment.