/** * @expectedException \RuntimeException * @expectedExceptionCode 3 */ public function testGetDefaultAndTooMany() { $exe1 = $this->createExecutor(); $exe2 = $this->createExecutor(); $reg = new ExecutorRegistry(); $reg->add('foo', $exe1, false); $reg->add('bar', $exe2, false); $reg->getDefault(); }
public function testRun() { $mockParams = array(); $mockRequestHandler = $this->getMock(RequestHandlerInterface::class); $mockRequestHandler->expects($this->once())->method('handle')->willReturn(42); $mockServer = new ServerStub(function (ServerContextInterface $context, RequestHandlerInterface $requestHandler) use(&$mockParams) { $mockParams = array('address' => $context->getListenAddress(), 'port' => $context->getListenPort(), 'handlerId' => $requestHandler->handle($this->getMock(RequestInterface::class))); }); $executor = new Executor($mockServer, $mockRequestHandler, $this->getMock(ExceptionHandlerInterface::class)); $this->executorRegistry->add('fooBar', $executor, false); $cmd = $this->createCommand(); $cmd->run(new ArrayInput(array('--listenAddress' => '1.1.1.1', '--listenPort' => 8080, '--executor' => 'fooBar')), new NullOutput()); $this->assertEquals(array('address' => '1.1.1.1', 'port' => 8080, 'handlerId' => 42), $mockParams); }