public function testConfigNotSet()
 {
     $mockService = $this->getMockBuilder('Heise\\Shariff\\Backend\\ServiceInterface')->getMock();
     $mockService->expects($this->never())->method('setConfig');
     $serviceFactory = new ServiceFactory(new Client());
     $serviceFactory->registerService('MockService', $mockService);
     $services = $serviceFactory->getServicesByName(array('MockService'), array('OtherService' => array('foo' => 'bar')));
     $this->assertCount(1, $services);
 }
Пример #2
0
 /**
  * Backend constructor.
  *
  * @param Cache $cache
  * @param ConfigRepositor $config
  */
 public function __construct(Cache $cache, ConfigRepositor $config)
 {
     $config = $config->get('shariff', []);
     $domain = $config['domain'];
     $clientOptions = [];
     if (isset($config['client'])) {
         $clientOptions = $config['client'];
     }
     $client = new Client(['defaults' => $clientOptions]);
     $baseCacheKey = md5(json_encode($config));
     $serviceFactory = new ServiceFactory($client);
     $this->backendManager = new BackendManager($baseCacheKey, $cache, $client, $domain, $serviceFactory->getServicesByName($config['services'], $config));
 }
Пример #3
0
 /**
  * @param array $config
  */
 public function __construct($config)
 {
     $domain = $config['domain'];
     $clientOptions = [];
     if (isset($config['client'])) {
         $clientOptions = $config['client'];
     }
     $client = new Client(['defaults' => $clientOptions]);
     $baseCacheKey = md5(json_encode($config));
     if (isset($config['cacheClass'])) {
         $cacheClass = $config['cacheClass'];
     } else {
         $cacheClass = 'Heise\\Shariff\\ZendCache';
     }
     $cache = new $cacheClass($config['cache']);
     $serviceFactory = new ServiceFactory($client);
     $this->backendManager = new BackendManager($baseCacheKey, $cache, $client, $domain, $serviceFactory->getServicesByName($config['services'], $config));
 }