/**
  * @expectedException \RuntimeException
  * @expectedExceptionCode 3
  */
 public function testGetDefaultAndTooMany()
 {
     $reqHand1 = $this->getMock(RequestHandlerInterface::class);
     $reqHand2 = $this->getMock(RequestHandlerInterface::class);
     $reg = new RequestHandlerRegistry();
     $reg->add('foo', $reqHand1, false);
     $reg->add('bar', $reqHand2, false);
     $reg->getDefault();
 }
 /**
  * @param $requestHandlerAlias
  *
  * @return RequestHandlerInterface
  */
 private function guessRequestHandler($requestHandlerAlias)
 {
     if (self::USE_DEFAULT_KEY == $requestHandlerAlias) {
         return $this->requestHandlerRegistry->getDefault();
     } elseif ($this->container->has($requestHandlerAlias)) {
         return $this->container->get($requestHandlerAlias);
     } else {
         return $this->requestHandlerRegistry->get($requestHandlerAlias);
     }
 }
 public function testDefaultAndSpecialAlias()
 {
     $mockServer1 = $this->getMock(ServerInterface::class);
     $mockServer2 = $this->getMock(ServerInterface::class);
     $this->serverRegistry->add('foo1', $mockServer1, false);
     $this->serverRegistry->add('foo2', $mockServer2, true);
     $mockRequestHandler1 = $this->getMock(RequestHandlerInterface::class);
     $mockRequestHandler2 = $this->getMock(RequestHandlerInterface::class);
     $this->requestHandlerRegistry->add('bar1', $mockRequestHandler1, false);
     $this->requestHandlerRegistry->add('bar2', $mockRequestHandler2, true);
     $exceptionHandler = $this->createExceptionHandler();
     $exe = $this->createFactory()->create(ExecutorFactory::USE_DEFAULT_KEY, ExecutorFactory::USE_DEFAULT_KEY, $exceptionHandler);
     /* @var ExecutorFakeStub $exe */
     $this->assertInstanceOf(ExecutorFakeStub::class, $exe);
     $this->assertSame($mockServer2, $exe->getServer());
     $this->assertSame($mockRequestHandler2, $exe->getRequestHandler());
     $this->assertSame($exceptionHandler, $exe->getExceptionHandler());
     $exe = $this->createFactory()->create('foo1', 'bar1', $exceptionHandler);
     /* @var ExecutorFakeStub $exe */
     $this->assertInstanceOf(ExecutorFakeStub::class, $exe);
     $this->assertSame($mockServer1, $exe->getServer());
     $this->assertSame($mockRequestHandler1, $exe->getRequestHandler());
     $this->assertSame($exceptionHandler, $exe->getExceptionHandler());
 }