diff --git a/lib/Ratchet/Application/ApplicationInterface.php b/lib/Ratchet/Application/ApplicationInterface.php new file mode 100644 index 0000000..a5c37a3 --- /dev/null +++ b/lib/Ratchet/Application/ApplicationInterface.php @@ -0,0 +1,12 @@ + null ); - public function __construct(ObserverInterface $app = null) { + public function __construct(ApplicationInterface $app = null) { if (null === $app) { throw new \UnexpectedValueException("WebSocket requires an application to run off of"); } diff --git a/lib/Ratchet/ObserverInterface.php b/lib/Ratchet/ObserverInterface.php index 2bec983..1b06a46 100644 --- a/lib/Ratchet/ObserverInterface.php +++ b/lib/Ratchet/ObserverInterface.php @@ -9,13 +9,6 @@ namespace Ratchet; * @todo Does this belong in \Ratchet\Server\? */ interface ObserverInterface { - /** - * Decorator pattern - * @param ObserverInterface If nothing is passed it's the end of the line - * @throws UnexpectedValueException - */ - public function __construct(ObserverInterface $app = null); - /** * When a new connection is opened it will be passed to this method * @param SocketInterface The socket/connection that just connected to your application diff --git a/tests/Ratchet/Tests/Mock/Application.php b/tests/Ratchet/Tests/Mock/Application.php index a32db0e..75b7a3b 100644 --- a/tests/Ratchet/Tests/Mock/Application.php +++ b/tests/Ratchet/Tests/Mock/Application.php @@ -1,11 +1,11 @@ AF_INET - , 'type' => SOCK_STREAM - , 'protocol' => SOL_TCP - , 'options' => array( - SOL_SOCKET => array(SO_REUSEADDR => 1) - ) - ); - } - - public function onOpen(SocketInterface $conn) { - } - - public function onRecv(SocketInterface $from, $msg) { - } - - public function onClose(SocketInterface $conn) { - } - - public function onError(SocketInterface $conn, \Exception $e) { - } -} \ No newline at end of file diff --git a/tests/Ratchet/Tests/Protocol/WebSocketTest.php b/tests/Ratchet/Tests/Protocol/WebSocketTest.php index 3402562..264e820 100644 --- a/tests/Ratchet/Tests/Protocol/WebSocketTest.php +++ b/tests/Ratchet/Tests/Protocol/WebSocketTest.php @@ -14,11 +14,6 @@ class WebSocketTest extends \PHPUnit_Framework_TestCase { $this->_ws = new WebSocket(new Application); } - public function testServerImplementsServerInterface() { - $constraint = $this->isInstanceOf('\\Ratchet\\ObserverInterface'); - $this->assertThat($this->_ws, $constraint); - } - public function testGetConfigReturnsArray() { $this->assertInternalType('array', $this->_ws->getDefaultConfig()); } diff --git a/tests/Ratchet/Tests/SocketTest.php b/tests/Ratchet/Tests/SocketTest.php index 14f784a..2176e13 100644 --- a/tests/Ratchet/Tests/SocketTest.php +++ b/tests/Ratchet/Tests/SocketTest.php @@ -2,7 +2,6 @@ namespace Ratchet\Tests; use Ratchet\Tests\Mock\FakeSocket as Socket; use Ratchet\Socket as RealSocket; -use Ratchet\Tests\Mock\Protocol; use Ratchet\Tests\Mock\Application as TestApp; /** @@ -45,24 +44,6 @@ class SocketTest extends \PHPUnit_Framework_TestCase { $this->_socket->fake_method(); } - public function testConstructionFromProtocolInterfaceConfig() { - $protocol = new Protocol(new TestApp); - $socket = Socket::createFromConfig($protocol); - - $this->assertInstanceOf('\\Ratchet\\Socket', $socket); - } - - public function testCreationFromConfigOutputMatchesInput() { - $protocol = new Protocol(new TestApp); - $socket = Socket::createFromConfig($protocol); - $config = $protocol::getDefaultConfig(); - - // change this to array_filter late - unset($config['options']); - - $this->assertAttributeEquals($config, '_arguments', $socket); - } - public function asArrayProvider() { return array( array(array('hello' => 'world'), array('hello' => 'world'))