Пример #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());
     $composerJson = ComposerJsonFactory::create($home);
     $this->assertInstanceOf(ComposerJson::class, $composerJson);
     $this->assertEquals($this->getTempDir() . DIRECTORY_SEPARATOR . 'composer.json', $composerJson->getFilename());
 }