diff options
author | marvin-borner@live.com | 2018-04-10 21:50:16 +0200 |
---|---|---|
committer | marvin-borner@live.com | 2018-04-10 21:54:48 +0200 |
commit | fc9401f04a3aca5abb22f87ebc210de8afe11d32 (patch) | |
tree | b0b310f3581764ec3955f4e496a05137a32951c3 /assets/php/vendor/react/socket/tests/SecureServerTest.php | |
parent | 286d643180672f20526f3dc3bd19d7b751e2fa97 (diff) |
Initial Commit
Diffstat (limited to 'assets/php/vendor/react/socket/tests/SecureServerTest.php')
-rw-r--r-- | assets/php/vendor/react/socket/tests/SecureServerTest.php | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/assets/php/vendor/react/socket/tests/SecureServerTest.php b/assets/php/vendor/react/socket/tests/SecureServerTest.php new file mode 100644 index 0000000..92c641f --- /dev/null +++ b/assets/php/vendor/react/socket/tests/SecureServerTest.php @@ -0,0 +1,105 @@ +<?php + +namespace React\Tests\Socket; + +use React\Socket\SecureServer; +use React\Socket\TcpServer; + +class SecureServerTest extends TestCase +{ + public function setUp() + { + if (!function_exists('stream_socket_enable_crypto')) { + $this->markTestSkipped('Not supported on your platform (outdated HHVM?)'); + } + } + + public function testGetAddressWillBePassedThroughToTcpServer() + { + $tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock(); + $tcp->expects($this->once())->method('getAddress')->willReturn('tcp://127.0.0.1:1234'); + + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $server = new SecureServer($tcp, $loop, array()); + + $this->assertEquals('tls://127.0.0.1:1234', $server->getAddress()); + } + + public function testGetAddressWillReturnNullIfTcpServerReturnsNull() + { + $tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock(); + $tcp->expects($this->once())->method('getAddress')->willReturn(null); + + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $server = new SecureServer($tcp, $loop, array()); + + $this->assertNull($server->getAddress()); + } + + public function testPauseWillBePassedThroughToTcpServer() + { + $tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock(); + $tcp->expects($this->once())->method('pause'); + + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $server = new SecureServer($tcp, $loop, array()); + + $server->pause(); + } + + public function testResumeWillBePassedThroughToTcpServer() + { + $tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock(); + $tcp->expects($this->once())->method('resume'); + + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $server = new SecureServer($tcp, $loop, array()); + + $server->resume(); + } + + public function testCloseWillBePassedThroughToTcpServer() + { + $tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock(); + $tcp->expects($this->once())->method('close'); + + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $server = new SecureServer($tcp, $loop, array()); + + $server->close(); + } + + public function testConnectionWillBeEndedWithErrorIfItIsNotAStream() + { + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $tcp = new TcpServer(0, $loop); + + $connection = $this->getMockBuilder('React\Socket\ConnectionInterface')->getMock(); + $connection->expects($this->once())->method('end'); + + $server = new SecureServer($tcp, $loop, array()); + + $server->on('error', $this->expectCallableOnce()); + + $tcp->emit('connection', array($connection)); + } + + public function testSocketErrorWillBeForwarded() + { + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); + + $tcp = new TcpServer(0, $loop); + + $server = new SecureServer($tcp, $loop, array()); + + $server->on('error', $this->expectCallableOnce()); + + $tcp->emit('error', array(new \RuntimeException('test'))); + } +} |