예제 #1
0
 /**
  * If an instance of Solarium_Client has not been created yet, create it.
  * @param DependencyContainer $container
  */
 protected function validateClient(DependencyContainer $container)
 {
     $client = $container->getClient();
     if (empty($client)) {
         $solariumConfig = $this->getSolariumClientConfig();
         $container->setClient(new Solarium_Client($solariumConfig));
     }
 }
예제 #2
0
 /**
  * @group Slow
  * @slowExecutionTime 0.09962 ms
  * @covers Wikia\Search\QueryService\DependencyContainer::__construct
  * @covers Wikia\Search\QueryService\DependencyContainer::getService
  * @covers Wikia\Search\QueryService\DependencyContainer::setService
  * @covers Wikia\Search\QueryService\DependencyContainer::getConfig
  * @covers Wikia\Search\QueryService\DependencyContainer::setConfig
  * @covers Wikia\Search\QueryService\DependencyContainer::getClient
  * @covers Wikia\Search\QueryService\DependencyContainer::setClient
  */
 public function testDependencyContainer()
 {
     $mockClient = $this->getMockBuilder('\\Solarium_Client')->disableOriginalConstructor()->getMock();
     $config = new Search\Config();
     $service = new Search\MediaWikiService();
     $factory = new Search\ResultSet\Factory();
     $dc = new Search\QueryService\DependencyContainer(array());
     $dc->setService($service)->setConfig($config)->setClient($mockClient);
     $this->assertEquals($mockClient, $dc->getClient());
     $this->assertEquals($config, $dc->getConfig());
     $this->assertEquals($service, $dc->getService());
 }
예제 #3
0
 /**
  * Handles dependency injection for all child classes.
  * @param DependencyContainer $container
  */
 public function __construct(DependencyContainer $container)
 {
     $this->client = $container->getClient();
     // this initializes the core assigned to the queryservice by default
     $this->config = $container->getConfig();
     $this->service = $container->getService();
 }