/**
  * @expectedException \RuntimeException
  * @expectedExceptionCode 3
  */
 public function testGetDefaultAndTooMany()
 {
     $serv1 = $this->getMock(ServerInterface::class);
     $serv2 = $this->getMock(ServerInterface::class);
     $reg = new ServerRegistry();
     $reg->add('foo', $serv1, false);
     $reg->add('bar', $serv2, false);
     $reg->getDefault();
 }
 /**
  * @param string $serverAlias
  *
  * @return ServerInterface
  */
 private function guessServer($serverAlias)
 {
     if (self::USE_DEFAULT_KEY == $serverAlias) {
         return $this->serverRegistry->getDefault();
     } elseif ($this->container->has($serverAlias)) {
         return $this->container->get($serverAlias);
     } else {
         return $this->serverRegistry->get($serverAlias);
     }
 }
 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());
 }