コード例 #1
0
 public function testPrintReport()
 {
     if (file_exists($file = CodeCoverageSession::getCacheFile())) {
         unlink($file);
     }
     $options = array('enabled' => true, 'output.text' => true, 'output.html' => getcwd(), 'output.clover' => getcwd() . '/clover.xml');
     static::$container->setParameter('session.results', array('some'));
     $runner = new CodeCoverageSession();
     $runner->setOptions($options);
     $runner->setContainer(static::$container);
     $event = new ProcessEvent(static::$container->get('plugins.test'));
     $genericEvent = new GenericEvent(static::$container);
     $genericEvent->addProcessEvent($event);
     // not display coverage when results file not exists
     $runner->process($genericEvent);
     $this->assertNotDisplayContains('html output');
     $this->assertNotDisplayContains('text output');
     $this->assertNotDisplayContains('clover output');
     // display coverage when cache file exists
     Filesystem::create()->serialize($file, $runner);
     $runner->process($genericEvent);
     $this->assertDisplayContains('html output');
     $this->assertDisplayContains('text output');
     $this->assertDisplayContains('clover output');
 }
コード例 #2
0
ファイル: BehatPlugin.php プロジェクト: phpguard/plugin-behat
 public function start(GenericEvent $event)
 {
     if ($this->options['all_on_start']) {
         $results = $this->container->get('behat.inspector')->runAll();
         $event->addProcessEvent(new ProcessEvent($this, $results));
     }
 }
コード例 #3
0
ファイル: Locator.php プロジェクト: phpguard/phpguard
 public function onApplicationInitialize(GenericEvent $event)
 {
     $container = $event->getContainer();
     if ($container->getParameter('application.initialized', false)) {
         return;
     }
     $logger = $container->get('logger');
     $logger->addDebug('Loading plugins');
     $prefixes = array_merge($this->prefixesPsr4);
     foreach ($prefixes as $ns => $dir) {
         $pluginPrefix = 'PhpGuard\\Plugins';
         $ns = rtrim($ns, '\\');
         if (false !== strpos($ns, $pluginPrefix)) {
             $parts = explode('\\', $ns);
             $lastPart = array_pop($parts);
             $class = $ns . '\\' . $lastPart . 'Plugin';
             $this->loadPlugin($container, $class);
         }
     }
     $container->setShared('linters.php', function ($c) {
         $linter = new PhpLinter();
         $linter->setContainer($c);
         return $linter;
     });
 }
コード例 #4
0
ファイル: LocatorSpec.php プロジェクト: phpguard/phpguard
 function it_should_not_load_plugin_when_application_initialized(ContainerInterface $container, GenericEvent $event)
 {
     $event->getContainer()->willReturn($container);
     $container->getParameter('application.initialized', false)->willReturn(true);
     $container->setShared(Argument::any(), Argument::any())->shouldNotBeCalled();
     $this->onApplicationInitialize($event);
 }
コード例 #5
0
 public function start(GenericEvent $event)
 {
     if ($this->options['all_on_start']) {
         $this->logger->addDebug('Begin executing all on start');
         $event->addProcessEvent($this->runAll());
         $this->logger->addDebug('End executing all on start');
     }
 }
コード例 #6
0
 function it_should_run_all_on_start_if_defined(Inspector $inspector, GenericEvent $event)
 {
     $event->addProcessEvent(Argument::any())->shouldBeCalled();
     $inspector->runAll()->shouldBeCalled()->willReturn(array());
     $options = array('all_on_start' => true);
     $this->setOptions($options);
     $this->start($event);
 }
コード例 #7
0
ファイル: Report.php プロジェクト: phpguard/phpguard
 public function summary(GenericEvent $event)
 {
     if (count($event->getProcessEvents()) > 0) {
         $this->container->get('ui.output')->writeln('');
         $this->container->get('ui.output')->writeln('');
         $this->container->get('logger')->addDebug('Print Summary');
         foreach ($event->getProcessEvents() as $processEvent) {
             $this->renderResult($processEvent);
         }
     }
 }
コード例 #8
0
 public function runAllCommand(GenericEvent $event)
 {
     /* @var \PhpGuard\Application\Plugin\PluginInterface $plugin */
     $this->container->setParameter('application.exit_code', 0);
     if (is_null($plugin = $event->getArgument('plugin'))) {
         $plugins = $this->container->getByPrefix('plugins');
     } else {
         $name = 'plugins.' . $plugin;
         if ($this->container->has($name)) {
             $plugin = $this->container->get('plugins.' . $plugin);
             $plugins = array($plugin);
         } else {
             throw new \RuntimeException(sprintf('Plugin "%s" is not registered', $plugin));
         }
     }
     foreach ($plugins as $plugin) {
         if (!$plugin->isActive()) {
             $this->getLogger()->addDebug(sprintf('Plugin "%s" is not active', $plugin->getTitle()));
             continue;
         } else {
             $this->getLogger()->addDebug('Start running all for plugin ' . $plugin->getTitle());
             $event->addProcessEvent($plugin->runAll());
             $this->getLogger()->addDebug('End running all for plugin ' . $plugin->getTitle());
         }
     }
 }
コード例 #9
0
 function let(ContainerInterface $container, PluginInterface $plugin, AdapterInterface $adapter, Listener $listener, ConsoleHandler $handler, Logger $logger, GenericEvent $event, InputInterface $input)
 {
     if (is_null(static::$cwd)) {
         static::$cwd = getcwd();
     }
     Filesystem::create()->mkdir(static::$tmpDir);
     $container->getByPrefix('plugins')->willReturn(array($plugin));
     $container->getParameter(Argument::any(), Argument::any())->willReturn(null);
     $container->setParameter(Argument::any(), Argument::any())->willReturn(null);
     $container->get('listen.listener')->willReturn($listener);
     $container->get('listen.adapter')->willReturn($adapter);
     $container->get('logger.handler')->willReturn($handler);
     $container->get('logger')->willReturn($logger);
     $event->getContainer()->willReturn($container);
     $container->get('ui.input')->willReturn($input);
     $this->setContainer($container);
 }
コード例 #10
0
 public function started(GenericEvent $event)
 {
     $this->setupListen($event->getContainer());
 }
コード例 #11
0
 public function process(GenericEvent $event)
 {
     $results = $event->getProcessEvents();
     if (empty($results) || !$this->isEnabled()) {
         return;
     }
     if (!$this->importCached()) {
         return;
     }
     $options = $this->options;
     if ($options['output.html']) {
         $this->reportHtml($options['output.html']);
     }
     if ($options['output.clover']) {
         $this->reportClover($options['output.clover']);
     }
     if ($options['output.text']) {
         $this->reportText();
     }
 }
コード例 #12
0
 public function load(GenericEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $container = $event->getContainer();
     $config = $container->get('config');
     $dispatcher->dispatch(ConfigEvents::PRELOAD, $event);
     $compiled = $config->compileFile($container->getParameter('config.file'));
     $container->setParameter('config.compiled', $compiled);
     $dispatcher->dispatch(ConfigEvents::POSTLOAD, $event);
     $container->get('logger')->addDebug('Configuration loaded');
 }
コード例 #13
0
 function let(GenericEvent $event, ContainerInterface $container, Logger $logger)
 {
     $container->get('logger')->willReturn($logger);
     $event->getContainer()->willReturn($container);
 }
コード例 #14
0
 function it_plugin_should_not_runAll_if_not_active(ContainerInterface $container, PluginInterface $active, PluginInterface $inactive, GenericEvent $event)
 {
     $event->getSubject()->willReturn($container);
     $event->getArgument('plugin')->willReturn(null);
     $event->addProcessEvent(Argument::any())->shouldBeCalled();
     $container->getByPrefix('plugins')->willReturn(array($active, $inactive));
     $container->has('active')->willReturn(true);
     $active->isActive()->shouldBeCalled()->willReturn(true);
     $active->runAll()->willReturn(new ProcessEvent($active->getWrappedObject(), array()));
     $active->getTitle()->willReturn('active');
     $container->has('inactive')->willReturn(true);
     $inactive->getName()->willReturn('inactive');
     $inactive->getTitle()->willReturn('Inactive');
     $inactive->isActive()->shouldBeCalled()->willReturn(false);
     $inactive->runAll(Argument::any())->shouldNotBeCalled();
     $this->runAllCommand($event);
 }