-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from clue-labs/phpunit
Forward compatibility with PHPUnit 6
- Loading branch information
Showing
5 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,16 +23,22 @@ public function setUp() | |
public function testCtorAcceptsUriWithHostAndPort() | ||
{ | ||
$client = new Client('127.0.0.1:9050', $this->connector); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
public function testCtorAcceptsUriWithScheme() | ||
{ | ||
$client = new Client('socks://127.0.0.1:9050', $this->connector); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
public function testCtorAcceptsUriWithHostOnlyAssumesDefaultPort() | ||
{ | ||
$client = new Client('127.0.0.1', $this->connector); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
/** | ||
|
@@ -46,6 +52,8 @@ public function testCtorThrowsForInvalidUri() | |
public function testValidAuthFromUri() | ||
{ | ||
$this->client = new Client('username:[email protected]', $this->connector); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
/** | ||
|
@@ -59,6 +67,8 @@ public function testInvalidAuthInformation() | |
public function testValidAuthAndVersionFromUri() | ||
{ | ||
$this->client = new Client('socks5://username:[email protected]:9050', $this->connector); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,15 +181,15 @@ public function testConnectionInvalidProtocolDoesNotMatchSocks5() | |
$this->server->setProtocolVersion(5); | ||
$this->client = new Client('socks4a://127.0.0.1:' . $this->port, $this->connector); | ||
|
||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), '', SOCKET_ECONNRESET); | ||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), null, SOCKET_ECONNRESET); | ||
} | ||
|
||
public function testConnectionInvalidProtocolDoesNotMatchSocks4() | ||
{ | ||
$this->server->setProtocolVersion(4); | ||
$this->client = new Client('socks5://127.0.0.1:' . $this->port, $this->connector); | ||
|
||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), '', SOCKET_ECONNRESET); | ||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), null, SOCKET_ECONNRESET); | ||
} | ||
|
||
public function testConnectionInvalidNoAuthentication() | ||
|
@@ -198,7 +198,7 @@ public function testConnectionInvalidNoAuthentication() | |
|
||
$this->client = new Client('socks5://127.0.0.1:' . $this->port, $this->connector); | ||
|
||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), '', SOCKET_EACCES); | ||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), null, SOCKET_EACCES); | ||
} | ||
|
||
public function testConnectionInvalidAuthenticationMismatch() | ||
|
@@ -207,7 +207,7 @@ public function testConnectionInvalidAuthenticationMismatch() | |
|
||
$this->client = new Client('user:[email protected]:' . $this->port, $this->connector); | ||
|
||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), '', SOCKET_EACCES); | ||
$this->assertRejectPromise($this->client->connect('www.google.com:80'), null, SOCKET_EACCES); | ||
} | ||
|
||
/** @group internet */ | ||
|
@@ -310,11 +310,21 @@ private function assertResolveStream($promise) | |
Block\await($promise, $this->loop, 2.0); | ||
} | ||
|
||
private function assertRejectPromise($promise, $message = '', $code = null) | ||
private function assertRejectPromise($promise, $message = null, $code = null) | ||
{ | ||
$this->expectPromiseReject($promise); | ||
|
||
$this->setExpectedException('Exception', $message, $code); | ||
if (method_exists($this, 'expectException')) { | ||
$this->expectException('Exception'); | ||
if ($message !== null) { | ||
$this->expectExceptionMessage($message); | ||
} | ||
if ($code !== null) { | ||
$this->expectExceptionCode($code); | ||
} | ||
} else { | ||
$this->setExpectedException('Exception', $message, $code); | ||
} | ||
|
||
Block\await($promise, $this->loop, 2.0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters