Beispiel #1
0
 /**
  * Create the default container containing all basic services.
  *
  * @param array $services Array of services to provide.
  *
  * @return Container
  */
 protected function createDefaultContainer($services = [])
 {
     $container = new Container();
     foreach ($services as $name => $service) {
         $container->set($name, $service);
     }
     if (!$container->has('event_dispatcher')) {
         $container->set('event_dispatcher', new EventDispatcher());
     }
     if (!$container->has('tenside.home')) {
         $home = $this->getMock(HomePathDeterminator::class, ['homeDir']);
         $home->method('homeDir')->willReturn($this->getTempDir());
         $container->set('tenside.home', $home);
     }
     if (!$container->has('tenside.config')) {
         $container->set('tenside.config', TensideJsonConfigFactory::create($container->get('tenside.home')));
     }
     if (!$container->has('tenside.taskfactory')) {
         $container->set('tenside.taskfactory', new ComposerTaskFactory($container->get('tenside.home')));
     }
     if (!$container->has('tenside.tasks')) {
         $container->set('tenside.tasks', TaskListFactory::create($container->get('tenside.home'), $container->get('tenside.taskfactory')));
     }
     if (!$container->has('tenside.composer_json')) {
         $container->set('tenside.composer_json', ComposerJsonFactory::create($container->get('tenside.home')));
     }
     if (!$container->has('tenside.status')) {
         $tenside = new InstallationStatusDeterminator($container->get('tenside.home'));
         $container->set('tenside.status', $tenside);
     }
     return $container;
 }
 /**
  * Test that the factory creates a new instance.
  *
  * @return void
  */
 public function testCreate()
 {
     $home = $this->getMock(HomePathDeterminator::class, ['homeDir']);
     $home->method('homeDir')->willReturn($this->getTempDir());
     $list = TaskListFactory::create($home, $factory = $this->getMockForAbstractClass(TaskFactoryInterface::class));
     $this->assertInstanceOf(TaskList::class, $list);
     $dataDir = new \ReflectionProperty($list, 'dataDir');
     $dataDir->setAccessible(true);
     $dispatcher = new \ReflectionProperty($list, 'factory');
     $dispatcher->setAccessible(true);
     $this->assertEquals($home->tensideDataDir(), $dataDir->getValue($list));
     $this->assertEquals($factory, $dispatcher->getValue($list));
 }