/**
  * @param ServiceContainer $container
  */
 public function build(ServiceContainer $container)
 {
     $assembler = $this;
     $container->addConfigurator(function ($c) use($assembler) {
         $config = $c->getParam('mage_locator', array('main' => ''));
         $srcNS = $assembler->getNamespace($config);
         $specPrefix = $assembler->getSpecPrefix($config);
         $srcPath = $assembler->getSrcPath($config);
         $specPath = $assembler->getSpecPath($config);
         $codePool = $assembler->getCodePool($config);
         $filesystem = $c->get('filesystem');
         if (!$filesystem->isDirectory($srcPath)) {
             $filesystem->makeDirectory($srcPath);
         }
         if (!$filesystem->isDirectory($specPath)) {
             $filesystem->makeDirectory($specPath);
         }
         $c->setShared('locator.locators.model_locator', function ($c) use($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool) {
             return new ModelLocator($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
         });
         $c->setShared('locator.locators.resource_model_locator', function ($c) use($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool) {
             return new ResourceModelLocator($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
         });
         $c->setShared('locator.locators.block_locator', function ($c) use($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool) {
             return new BlockLocator($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
         });
         $c->setShared('locator.locators.helper_locator', function ($c) use($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool) {
             return new HelperLocator($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
         });
         $c->setShared('locator.locators.controller_locator', function ($c) use($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool) {
             return new ControllerLocator($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
         });
     });
 }
 /**
  * {@inheritdoc}
  *
  * @link https://github.com/phpspec/phpspec/blob/36c1e97d59630888fd022a542b1650ae5eab1f18/src/PhpSpec/Console/ContainerAssembler.php#L338
  */
 public function load(ServiceContainer $container)
 {
     $container->addConfigurator(function (ServiceContainer $c) {
         $resourceManager = $c->get('locator.resource_manager');
         $suites = $c->getParam('suites', array('main' => ''));
         foreach ($suites as $name => $suite) {
             $suite = is_array($suite) ? $suite : array('namespace' => $suite);
             $defaults = array('namespace' => '', 'spec_prefix' => 'spec', 'src_path' => 'src', 'spec_path' => '.', 'psr4_prefix' => null);
             $config = array_merge($defaults, $suite);
             $locator = new FQCNLocator($config['namespace'], $config['spec_prefix'], $config['src_path'], $config['spec_path'], null, $config['psr4_prefix']);
             $resourceManager->registerLocator($locator);
         }
     });
 }
 protected function setupLocators(ServiceContainer $container)
 {
     $container->setShared('locator.resource_manager', function ($c) {
         $manager = new ResourceManager();
         array_map(array($manager, 'registerLocator'), $c->getByPrefix('locator.locators'));
         return $manager;
     });
     $container->addConfigurator(function ($c) {
         $suites = $c->getParam('suites', array('main' => ''));
         foreach ($suites as $name => $suite) {
             $suite = $this->loadSuiteInformations($suite);
             $this->buildDirectories($suite);
             $c->set(sprintf('locator.locators.no_spec_%s_suite', $name), function ($c) use($suite) {
                 return new NoSpecLocator($c->get('well.utils.inspector'), $suite['srcNS'], $suite['specPrefix'], $suite['srcPath'], $suite['specPath']);
             });
         }
     });
 }
 /**
  * Set up Locator services for each phpspec suite configured, which may have
  * different class filename extensions.
  *
  * @param ServiceContainer $container
  */
 private function setupLocators(ServiceContainer $container)
 {
     $container->addConfigurator(function ($c) {
         $suites = $c->getParam('suites');
         foreach ($suites as $suite => $config) {
             // Not keen on how we have to track these config directives...
             $srcPath = $this->configParamOrDefault('src_path', $config, 'src');
             $specPath = $this->configParamOrDefault('spec_path', $config, '.');
             $srcNamespace = $this->configParamOrDefault('namespace', $config, '');
             $specNamespacePrefix = $this->configParamOrDefault('spec_prefix', $config, 'spec');
             $psr4Prefix = $this->configParamOrDefault('psr4_prefix', $config, null);
             $extension = $this->configParamOrDefault('src_extension', $config, '.php');
             $c->setShared('locator.locators.rdm.class_locator_' . $suite, function ($c) use($srcNamespace, $specNamespacePrefix, $srcPath, $specPath, $psr4Prefix, $extension) {
                 $l = new SuffixablePSR0Locator($srcNamespace, $specNamespacePrefix, $srcPath, $specPath, null, $psr4Prefix, $extension);
                 return $l;
             });
         }
         $resourceManager = $c->get('locator.resource_manager');
         array_map(array($resourceManager, 'registerLocator'), $c->getByPrefix('locator.locators.rdm'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 public function build(ServiceContainer $container)
 {
     $assembler = $this;
     $container->addConfigurator(function ($c) use($assembler) {
         $config = $c->getParam('wp_locator', array('main' => ''));
         $srcNS = $assembler->getNamespace($config);
         $specPrefix = $assembler->getSpecPrefix($config);
         $srcPath = $assembler->getSrcPath($config);
         $specPath = $assembler->getSpecPath($config);
         $filesystem = $c->get('filesystem');
         if (!$filesystem->isDirectory($srcPath)) {
             $filesystem->makeDirectory($srcPath);
         }
         if (!$filesystem->isDirectory($specPath)) {
             $filesystem->makeDirectory($specPath);
         }
         $c->setShared('locator.locators.wp_locator', function ($c) use($srcNS, $specPrefix, $srcPath, $specPath, $filesystem) {
             return new WpLocator($srcNS, $specPrefix, $srcPath, $specPath, $filesystem);
         });
     });
 }
 /**
  * @param ServiceContainer $container
  */
 private function setupSubscribers(ServiceContainer $container)
 {
     $container->addConfigurator(function (ServiceContainer $c) {
         array_map(array($c->get('event_dispatcher'), 'addSubscriber'), $c->getByPrefix('event_dispatcher.listeners'));
     });
 }
 /**
  * @param ServiceContainer $container
  */
 protected function setupFormatter(ServiceContainer $container)
 {
     $container->set('formatter.formatters.progress', function ($c) {
         return new Formatter\ProgressFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
     });
     $container->set('formatter.formatters.pretty', function ($c) {
         return new Formatter\PrettyFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
     });
     $container->set('formatter.formatters.junit', function ($c) {
         return new Formatter\JUnitFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
     });
     $container->set('formatter.formatters.dot', function ($c) {
         return new Formatter\DotFormatter($c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats'));
     });
     $container->set('formatter.formatters.html', function ($c) {
         $io = new Formatter\Html\IO();
         $template = new Formatter\Html\Template($io);
         $factory = new Formatter\Html\ReportItemFactory($template);
         $presenter = new Formatter\Html\HtmlPresenter($c->get('formatter.presenter.differ'));
         return new Formatter\HtmlFormatter($factory, $presenter, $io, $c->get('event_dispatcher.listeners.stats'));
     });
     $container->set('formatter.formatters.h', function ($c) {
         return $c->get('formatter.formatters.html');
     });
     $container->addConfigurator(function ($c) {
         $formatterName = $c->getParam('formatter.name', 'progress');
         $c->get('console.output')->setFormatter(new \PhpSpec\Console\Formatter($c->get('console.output')->isDecorated()));
         try {
             $formatter = $c->get('formatter.formatters.' . $formatterName);
         } catch (\InvalidArgumentException $e) {
             throw new RuntimeException(sprintf('Formatter not recognised: "%s"', $formatterName));
         }
         $c->set('event_dispatcher.listeners.formatter', $formatter);
     });
 }
Beispiel #8
0
 /**
  * @param ServiceContainer $container
  */
 private function assembleTypePresenters(ServiceContainer $container)
 {
     $container->setShared('formatter.presenter.value.array_type_presenter', function () {
         return new ArrayTypePresenter();
     });
     $container->setShared('formatter.presenter.value.boolean_type_presenter', function () {
         return new BooleanTypePresenter();
     });
     $container->setShared('formatter.presenter.value.callable_type_presenter', function (ServiceContainer $c) {
         return new CallableTypePresenter($c->get('formatter.presenter'));
     });
     $container->setShared('formatter.presenter.value.exception_type_presenter', function () {
         return new BaseExceptionTypePresenter();
     });
     $container->setShared('formatter.presenter.value.null_type_presenter', function () {
         return new NullTypePresenter();
     });
     $container->setShared('formatter.presenter.value.object_type_presenter', function () {
         return new ObjectTypePresenter();
     });
     $container->setShared('formatter.presenter.value.string_type_presenter', function () {
         return new TruncatingStringTypePresenter(new QuotingStringTypePresenter());
     });
     $container->addConfigurator(function (ServiceContainer $c) {
         array_map(array($c->get('formatter.presenter.value_presenter'), 'addTypePresenter'), $c->getByPrefix('formatter.presenter.value'));
     });
 }
Beispiel #9
0
 function let(ServiceContainer $container)
 {
     $container->setShared(Argument::cetera())->willReturn();
     $container->addConfigurator(Argument::any())->willReturn();
     $container->getParam(Argument::cetera())->willReturn();
 }