public function testCreateConnection() { $server = stream_socket_server('tcp://localhost:37234'); $loop = $this->getMock('React\\EventLoop\\LoopInterface'); $factory = new Factory($loop); $conn = $factory->createConnection(array('host' => 'localhost', 'port' => 37234)); $this->assertInstanceOf('React\\Socket\\Connection', $conn); }
/** @test */ public function itShouldThrowAnExceptionInCaseSocketCreationFails() { $loop = $this->getMock('React\\EventLoop\\LoopInterface'); $factory = new Factory($loop); try { $factory->createConnection(array('host' => 'localhost', 'port' => 37235)); $this->fail('This should have raised an exception'); } catch (ConnectionException $e) { } }