get() public method

Retrieves a service from the container
public get ( string $id ) : object
$id string
return object
 function it_creates_collaborator_maintainer_factory(ParameterValidator $parameterValidator)
 {
     $this->serviceContainer->get('ecomdev.phpspec.magento_di_adapter.parameter_validator')->willReturn($parameterValidator)->shouldBeCalled();
     $factory = $this->collaboratorMaintainerFactory();
     $factory->shouldImplement(\Closure::class);
     $factory($this->serviceContainer)->shouldImplement(CollaboratorMaintainer::class);
 }
Ejemplo n.º 2
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $helperSet = $this->getHelperSet();
     $this->container->set('console.input', $input);
     $this->container->set('console.output', $output);
     $this->container->setShared('console.prompter.factory', function ($c) use($helperSet) {
         return new Factory($c->get('console.input'), $c->get('console.output'), $helperSet);
     });
     $this->container->setShared('process.executioncontext', function () {
         return JsonExecutionContext::fromEnv($_SERVER);
     });
     $assembler = new ContainerAssembler();
     $assembler->build($this->container);
     $this->loadConfigurationFile($input, $this->container);
     foreach ($this->container->getByPrefix('console.commands') as $command) {
         $this->add($command);
     }
     $this->setDispatcher($this->container->get('console_event_dispatcher'));
     $this->container->get('console.io')->setConsoleWidth($this->getTerminalWidth());
     StreamWrapper::reset();
     foreach ($this->container->getByPrefix('loader.resource_loader.spec_transformer') as $transformer) {
         StreamWrapper::addTransformer($transformer);
     }
     StreamWrapper::register();
     return parent::doRun($input, $output);
 }
Ejemplo n.º 3
0
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     $container->setShared('phpspec_extension.git.repository', function () {
         return GitRepository::fromCurrentWorkingDirectory();
     });
     // N.B. - this is not ideal, but there appears to be no other way to achieve this currently.
     $classGenerator = $container->get('code_generator.generators.class');
     $specGenerator = $container->get('code_generator.generators.specification');
     $interfaceGenerator = $container->get('code_generator.generators.interface');
     $this->decorateGenerator($container, 'code_generator.generators.class', $classGenerator);
     $this->decorateGenerator($container, 'code_generator.generators.specification', $specGenerator);
     $this->decorateGenerator($container, 'code_generator.generators.interface', $interfaceGenerator);
 }
Ejemplo n.º 4
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->container->set('console.input', $input);
     $this->container->set('console.output', $output);
     $this->container->set('console.helper.dialog', $this->getHelperSet()->get('dialog'));
     $assembler = new ContainerAssembler();
     $assembler->build($this->container);
     $this->loadConfigurationFile($input, $this->container);
     foreach ($this->container->getByPrefix('console.commands') as $command) {
         $this->add($command);
     }
     $this->setDispatcher($this->container->get('console_event_dispatcher'));
     return parent::doRun($input, $output);
 }
Ejemplo n.º 5
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $helperSet = $this->getHelperSet();
     $this->container->set('console.input', $input);
     $this->container->set('console.output', $output);
     $this->container->setShared('console.prompter.factory', function ($c) use($helperSet) {
         return new Factory($c->get('console.input'), $c->get('console.output'), $helperSet);
     });
     $assembler = new ContainerAssembler();
     $assembler->build($this->container);
     $this->loadConfigurationFile($input, $this->container);
     foreach ($this->container->getByPrefix('console.commands') as $command) {
         $this->add($command);
     }
     $this->setDispatcher($this->container->get('console_event_dispatcher'));
     $this->container->get('console.io')->setConsoleWidth($this->getTerminalWidth());
     return parent::doRun($input, $output);
 }
 function let(SpecificationNode $specificationNode, ExampleEvent $exampleEvent, ServiceContainer $container, CodeCoverageSession $coverageSession)
 {
     $r = new \ReflectionClass(__CLASS__);
     $specificationNode->getClassReflection()->willReturn($r);
     $specificationNode->getTitle()->willReturn('Specification');
     $exampleEvent->getSpecification()->willReturn($specificationNode);
     $exampleEvent->getTitle()->willReturn('it should do something');
     $this->cwd = getcwd();
     chdir(sys_get_temp_dir());
     $container->get('coverage.session')->willReturn($coverageSession);
     $this->setCoverageRunner($coverageSession);
     $this->load($container);
 }
Ejemplo n.º 7
0
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     /** @var IO $io */
     $io = $container->get('console.io');
     if (!extension_loaded('xdebug')) {
         $io->writeln('<fg=white;bg=red>Code coverage disabled (missing xdebug extension)</>');
         return;
     }
     $container->setShared('event_dispatcher.listeners.addvilz_code_coverage', function (ServiceContainer $container) use($io) {
         $defaults = ['max_specs' => 1];
         $options = array_merge($defaults, $container->getParam('phpspec_cover', []));
         $listener = new Listener(new \PHP_CodeCoverage(), $io, new Reporter(new OutputFormatter($io->isDecorated())), $options['max_specs']);
         register_shutdown_function([$listener, 'shutdown']);
         return $listener;
     });
 }
Ejemplo n.º 8
0
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     dd($container->get('laravel')->app);
 }
 function let(ServiceContainer $serviceContainer, InputInterface $input)
 {
     $input->getOption('list-brob')->willReturn(true);
     $serviceContainer->get('console.input')->willReturn($input);
     $this->beConstructedWith($serviceContainer);
 }
 public function load(ServiceContainer $container)
 {
     $container->set('formatter.formatters.teamcity', function (ServiceContainer $container) {
         return new Formatter($container->get('formatter.presenter'), $container->get('console.io'), $container->get('event_dispatcher.listeners.stats'));
     });
 }
Ejemplo n.º 11
0
 private function defineupGenerators(ServiceContainer $container)
 {
     $container->define('code_generator.generators.method', function (ServiceContainer $container) {
         return new \Memio\SpecGen\MethodGenerator($container->get('memio_spec_gen.command_bus'));
     }, self::CODE_GENERATOR_TAG);
     $container->define('code_generator.generators.constructor', function (ServiceContainer $container) {
         return new \Memio\SpecGen\ConstructorGenerator($container->get('memio_spec_gen.command_bus'));
     }, self::CODE_GENERATOR_TAG);
 }
 /**
  * {@inheritDoc}
  */
 public function load(ServiceContainer $container)
 {
     $container->setShared('code_coverage.filter', function () {
         return new \PHP_CodeCoverage_Filter();
     });
     $container->setShared('code_coverage', function ($container) {
         return new \PHP_CodeCoverage(null, $container->get('code_coverage.filter'));
     });
     $container->setShared('code_coverage.options', function ($container) {
         $options = $container->getParam('code_coverage');
         if (!isset($options['format'])) {
             $options['format'] = array('html');
         } elseif (!is_array($options['format'])) {
             $options['format'] = (array) $options['format'];
         }
         if (isset($options['output'])) {
             if (!is_array($options['output']) && count($options['format']) == 1) {
                 $format = $options['format'][0];
                 $options['output'] = array($format => $options['output']);
             }
         }
         if (!isset($options['show_uncovered_files'])) {
             $options['show_uncovered_files'] = true;
         }
         if (!isset($options['lower_upper_bound'])) {
             $options['lower_upper_bound'] = 35;
         }
         if (!isset($options['high_lower_bound'])) {
             $options['high_lower_bound'] = 70;
         }
         return $options;
     });
     $container->setShared('code_coverage.reports', function ($container) {
         $options = $container->get('code_coverage.options');
         $reports = array();
         foreach ($options['format'] as $format) {
             switch ($format) {
                 case 'clover':
                     $reports['clover'] = new \PHP_CodeCoverage_Report_Clover();
                     break;
                 case 'php':
                     $reports['php'] = new \PHP_CodeCoverage_Report_PHP();
                     break;
                 case 'text':
                     $reports['text'] = new \PHP_CodeCoverage_Report_Text($options['lower_upper_bound'], $options['high_lower_bound'], $options['show_uncovered_files'], false);
                     break;
                 case 'xml':
                     $reports['xml'] = new \PHP_CodeCoverage_Report_XML();
                     break;
                 case 'crap4j':
                     $reports['crap4j'] = new \PHP_CodeCoverage_Report_Crap4j();
                     break;
                 case 'html':
                     $reports['html'] = new \PHP_CodeCoverage_Report_HTML();
                     break;
             }
         }
         $container->setParam('code_coverage', $options);
         return $reports;
     });
     $container->setShared('event_dispatcher.listeners.code_coverage', function ($container) {
         $listener = new CodeCoverageListener($container->get('code_coverage'), $container->get('code_coverage.reports'));
         $listener->setIO($container->get('console.io'));
         $listener->setOptions($container->getParam('code_coverage', array()));
         return $listener;
     });
 }
 /**
  * @param ServiceContainer $serviceContainer
  */
 public function __construct(ServiceContainer $serviceContainer)
 {
     $this->input = $serviceContainer->get('console.input');
     $this->params = $serviceContainer->getParam('brobdingnagian');
 }