public function createDelegatorWithName(ServiceLocatorInterface $services, $name, $requestedName, $callback)
 {
     /*@var DefaultAuthenticationListener $listener*/
     $listener = $callback();
     $config = $services->get('Config');
     if (!isset($config['zf-mvc-auth']['authentication']['adapters']) || !is_array($config['zf-mvc-auth']['authentication']['adapters'])) {
         return $listener;
     }
     foreach ($config['zf-mvc-auth']['authentication']['adapters'] as $type => $data) {
         if (!isset($data['adapter']) || !is_string($data['adapter'])) {
             continue;
         }
         switch ($data['adapter']) {
             case 'Schmiddim\\MvcAuth\\Adapter\\ApiKeyAdapter':
                 $adapter = AuthenticationApiKeyAdapterFactory::factory($type, $data, $services);
                 break;
             case 'ZF\\MvcAuth\\Authentication\\HttpAdapter':
                 $adapter = AuthenticationHttpAdapterFactory::factory($type, $data, $services);
                 break;
             case 'ZF\\MvcAuth\\Authentication\\OAuth2Adapter':
                 $adapter = AuthenticationOAuth2AdapterFactory::factory($type, $data, $services);
                 break;
             default:
                 $adapter = false;
                 break;
         }
         if ($adapter) {
             $listener->attach($adapter);
         }
     }
     return $listener;
 }
 /**
  * @dataProvider validConfiguration
  */
 public function testCreatesHttpAdapterWhenConfigurationIsValid(array $options, array $provides)
 {
     $authService = $this->getMock('Zend\\Authentication\\AuthenticationService');
     $this->services->expects($this->atLeastOnce())->method('has')->with($this->equalTo('authentication'))->will($this->returnValue(true));
     $this->services->expects($this->atLeastOnce())->method('get')->with($this->equalTo('authentication'))->will($this->returnValue($authService));
     $adapter = AuthenticationHttpAdapterFactory::factory('foo', ['options' => $options], $this->services);
     $this->assertInstanceOf('ZF\\MvcAuth\\Authentication\\HttpAdapter', $adapter);
     $this->assertEquals($provides, $adapter->provides());
 }
 /**
  * Attach an adaper to the listener as described by $type and $data.
  *
  * @param string $type
  * @param array $adapterConfig
  * @param ContainerInterface $container
  * @param DefaultAuthenticationListener $listener
  */
 private function attachAdapterOfType($type, array $adapterConfig, ContainerInterface $container, DefaultAuthenticationListener $listener)
 {
     if (!isset($adapterConfig['adapter']) || !is_string($adapterConfig['adapter'])) {
         return;
     }
     switch ($adapterConfig['adapter']) {
         case HttpAdapter::class:
             $adapter = AuthenticationHttpAdapterFactory::factory($type, $adapterConfig, $container);
             break;
         case OAuth2Adapter::class:
             $adapter = AuthenticationOAuth2AdapterFactory::factory($type, $adapterConfig, $container);
             break;
         default:
             $adapter = false;
             break;
     }
     if (!$adapter) {
         return;
     }
     $listener->attach($adapter);
 }