-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
152 additions
and
18 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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
<?php | |||
namespace PEAR2\Net\Transmitter; | |||
|
|||
class ClientTest extends \PHPUnit_Framework_TestCase | |||
{ | |||
|
|||
/** | |||
* @var SocketClientTransmitter | |||
*/ | |||
protected $client; | |||
|
|||
public function setUp() | |||
{ | |||
$this->client = new SocketClientTransmitter( | |||
REMOTE_HOSTNAME, REMOTE_PORT | |||
); | |||
} | |||
|
|||
public function tearDown() | |||
{ | |||
unset($this->client); | |||
} | |||
|
|||
public function testOneByteEcho() | |||
{ | |||
$byte = 't'; | |||
$this->client->send($byte); | |||
$this->assertEquals( | |||
$byte, $this->client->receive(1), 'Wrong byte echoed.' | |||
); | |||
} | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
<?php | |||
namespace PEAR2\Net\Transmitter; | |||
|
|||
class ServerTest extends \PHPUnit_Framework_TestCase | |||
{ | |||
|
|||
/** | |||
* @var resource | |||
*/ | |||
protected static $server; | |||
|
|||
/** | |||
* @var int | |||
*/ | |||
protected static $errorno; | |||
|
|||
/** | |||
* @var string | |||
*/ | |||
protected static $errstr; | |||
|
|||
/** | |||
* @var SocketServerConnectionTransmitter | |||
*/ | |||
protected $conn; | |||
|
|||
public static function setUpBeforeClass() | |||
{ | |||
self::$server = stream_socket_server( | |||
'tcp://' . LOCAL_HOSTNAME . ':' . LOCAL_PORT, | |||
self::$errorno, self::$errstr | |||
); | |||
} | |||
|
|||
public static function tearDownAfterClass() | |||
{ | |||
fclose(self::$server); | |||
} | |||
|
|||
public function setUp() | |||
{ | |||
$this->conn = new SocketServerConnectionTransmitter( | |||
self::$server, 1/*h*/ * 60/*m*/ * 60/*s*/ | |||
); | |||
} | |||
|
|||
public function tearDown() | |||
{ | |||
unset($this->conn); | |||
} | |||
|
|||
public function testOneByteEcho() | |||
{ | |||
$this->assertEquals( | |||
1, $this->conn->send($this->conn->receive(1)), 'Wrong byte echoed.' | |||
); | |||
} | |||
} |
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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
phpunit --configuration secondaryPeer.xml |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<phpunit | |||
bootstrap="bootstrap.php" | |||
colors="false" | |||
stopOnFailure="false" | |||
verbose="true" | |||
strict="true" | |||
|
|||
convertErrorsToExceptions="true" | |||
convertNoticesToExceptions="true" | |||
convertWarningsToExceptions="true" | |||
> | |||
<!-- | |||
convertErrorsToExceptions="false" | |||
convertNoticesToExceptions="false" | |||
convertWarningsToExceptions="false" | |||
> | |||
--> | |||
<php> | |||
<!-- | |||
The name and port of phpunit.xml | |||
--> | |||
<const name="REMOTE_HOSTNAME" value="127.0.0.1" /> | |||
<const name="REMOTE_PORT" value="6667" /> | |||
<!-- | |||
The name and port phpunit.xml must use. | |||
--> | |||
<const name="LOCAL_HOSTNAME" value="127.0.0.1" /> | |||
<const name="LOCAL_PORT" value="6666" /> | |||
</php> | |||
<testsuites> | |||
<testsuite name="All tests"> | |||
<file>ServerTest.php</file> | |||
<file>ClientTest.php</file> | |||
</testsuite> | |||
</testsuites> | |||
<filter> | |||
<whitelist> | |||
<directory suffix=".php">../src/PEAR2/Net/Transmitter</directory> | |||
</whitelist> | |||
</filter> | |||
</phpunit> |