/** * @param ContainerInterface $container * @param $port * @return SocketListener */ private static function makeSocketListener(ContainerInterface $container, $port) { $socketListener = new SocketListener('127.0.0.1', $port); $inputProcessor = new SocketInputProcessor($container); $socketListener->setInputProcessor($inputProcessor); return $socketListener; }
function getContainerDaemon($container, $port) { $socketListener = new SocketListener('127.0.0.1', $port); $inputProcessor = new SocketInputProcessor($container); $socketListener->setInputProcessor($inputProcessor); return new SocketDaemon($socketListener); }
public function testRun() { $socketListener = new SocketListener('127.0.0.1', 7080); $this->assertFalse($socketListener->isListening()); $phpUnit = $this; $socketListener->setAfterListen(function (SocketListener $listener) use($phpUnit) { static $tick = -1; $tick++; if (!$tick) { $phpUnit->assertTrue($listener->isListening()); return true; } $listener->stop(); $this->assertFalse($listener->isListening()); }); $socketListener->run(); }