Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"react/socket": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35",
"phpunit/phpunit": "^9.0 || ^7.0 || ^6.0 || ^5.7 || ^4.8.35",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
"clue/connection-manager-extra": "^1.0 || ^0.7",
"clue/block-react": "^1.1"
Expand Down
21 changes: 8 additions & 13 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class ClientTest extends TestCase
/** @var Client */
private $client;

public function setUp()
/**
* @before
*/
public function setUpMocks()
{
$this->loop = \React\EventLoop\Factory::create();
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
Expand Down Expand Up @@ -72,11 +75,9 @@ public function testCtorAcceptsUriWithSocks5UnixScheme()
$this->assertTrue(true);
}

/**
* @expectedException InvalidArgumentException
*/
public function testCtorThrowsForInvalidUri()
{
$this->setExpectedException("InvalidArgumentException");
new Client('////', $this->connector);
}

Expand All @@ -87,11 +88,9 @@ public function testValidAuthFromUri()
$this->assertTrue(true);
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidAuthInformation()
{
$this->setExpectedException("InvalidArgumentException");
new Client(str_repeat('a', 256) . ':[email protected]', $this->connector);
}

Expand All @@ -102,19 +101,15 @@ public function testValidAuthAndVersionFromUri()
$this->assertTrue(true);
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidCanNotSetAuthenticationForSocks4Uri()
{
$this->setExpectedException("InvalidArgumentException");
$this->client = new Client('socks4://username:[email protected]:9050', $this->connector);
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidProtocolVersion()
{
$this->setExpectedException("InvalidArgumentException");
$this->client = new Client('socks3://127.0.0.1:9050', $this->connector);
}

Expand Down
5 changes: 4 additions & 1 deletion tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class FunctionalTest extends TestCase
private $port;
private $server;

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

Expand Down
9 changes: 5 additions & 4 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class ServerTest extends TestCase
/** @var Server */
private $server;

public function setUp()
/**
* @before
*/
public function setUpServer()
{
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')
->getMock();
Expand Down Expand Up @@ -54,11 +57,9 @@ public function testConstructorWithStaticAuthArray()
));
}

/**
* @expectedException InvalidArgumentException
*/
public function testConstructorWithInvalidAuthenticatorThrows()
{
$this->setExpectedException("InvalidArgumentException");
new Server($this->loop, $this->connector, true);
}

Expand Down
13 changes: 6 additions & 7 deletions tests/StreamReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class StreamReaderTest extends TestCase
{
private $reader;

public function setUp()
/**
* @before
*/
public function setUpReader()
{
$this->reader = new StreamReader();
}
Expand Down Expand Up @@ -66,19 +69,15 @@ public function testSequence()
$this->assertEquals('rld', $this->reader->getBuffer());
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidStructure()
{
$this->setExpectedException("InvalidArgumentException");
$this->reader->readBinary(array('invalid' => 'y'));
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidCallback()
{
$this->setExpectedException("InvalidArgumentException");
$this->reader->readBufferCallback(array());
}
}
14 changes: 14 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,18 @@ protected function expectPromiseReject($promise)

return $promise;
}

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);
}
}

}