/**
  * @dataProvider getDataForTestingGetClassAndOptions
  */
 public function testGetService($configKey, $rawConfig, $expectedClass, $expectedOptions)
 {
     $service = $this->builder->getService($rawConfig, $configKey);
     $this->assertInstanceOf($expectedClass, $service);
     if (!empty($expectedOptions)) {
         $this->assertAttributeEquals($expectedOptions, 'options', $service);
     }
 }
Example #2
0
 /**
  * Inject a service.
  * 
  * @param string $id
  * @param mixed  $service
  * @param array  $options
  * @throws \InvalidArgumentException
  */
 public function setService($id, $service, array $options = array())
 {
     if (is_string($service)) {
         $builder = new Helpers\ServiceBuilder($this);
         $config = array_merge($options, array('name' => $service));
         $service = $builder->getService($config, '');
     }
     if (!is_object($service)) {
         throw new \InvalidArgumentException("setService() only accept an object or a valid class name");
     }
     $this->services[$id] = $service;
 }