Exemplo n.º 1
0
 function it_should_terminate_application(GenericEvent $event, ContainerInterface $container, Application $application, PhpGuard $phpGuard)
 {
     $container->get('ui.application')->shouldBeCalled()->willReturn($application);
     $container->get('phpguard')->shouldBeCalled()->willReturn($phpGuard);
     $application->exitApplication()->shouldBeCalled();
     $phpGuard->stop()->shouldBeCalled();
     $this->terminated($event);
 }
Exemplo n.º 2
0
 function let(ContainerInterface $container, Inspector $inspector, Runner $runner)
 {
     $container->get('behat.inspector')->willReturn($inspector);
     $container->setShared('behat.inspector', Argument::any())->willReturn();
     $container->has('behat.inspector')->willReturn(false);
     $container->get('runner')->willReturn($runner);
     $this->setContainer($container);
     $this->configure();
 }
Exemplo n.º 3
0
 function let(ContainerInterface $container, PhpGuard $phpGuard, Application $application, OutputInterface $output, OutputFormatterInterface $outputFormatter, EventDispatcherInterface $dispatcher)
 {
     $container->get('phpguard')->willReturn($phpGuard);
     $container->get('ui.application')->willReturn($application);
     $container->get('ui.output')->willReturn($output);
     $container->get('dispatcher')->willReturn($dispatcher);
     $output->getFormatter()->willreturn($outputFormatter);
     $output->write(Argument::any())->willReturn();
     $this->beAnInstanceOf('PhpGuard\\Application\\Test\\TestShell', array($container));
 }
Exemplo n.º 4
0
 function let(ContainerInterface $container, OutputInterface $output, PhpGuard $phpGuard, Inspector $inspector)
 {
     $container->get('ui.output')->willReturn($output);
     $container->get('phpguard')->willReturn($phpGuard);
     $container->get('phpunit.inspector')->willReturn($inspector);
     $container->setShared('phpunit.inspector', Argument::any())->willReturn();
     $logger = new Logger('PhpUnit');
     $this->setLogger($logger);
     $this->setContainer($container);
 }
Exemplo n.º 5
0
 function let(ContainerInterface $container, OutputInterface $output, Logger $logger, Process $process, ProcessBuilder $builder)
 {
     $builder->getProcess()->willReturn($process);
     $process->getCommandLine()->willReturn('some_command');
     $process->getExitCode()->willReturn(0);
     $process->getExitCodeText()->willReturn('exit_code_text');
     $container->get('runner.logger')->willReturn($logger);
     $container->get('ui.output')->willReturn($output);
     $container->getParameter('runner.tty', false)->willReturn(false);
     $container->getParameter('runner.default_dirs')->willReturn(array());
     $this->setContainer($container);
 }
Exemplo n.º 6
0
 function let(ContainerInterface $container, Runner $runner, Process $process, Logger $logger, PluginInterface $plugin)
 {
     $this->cacheFile = Inspector::getCacheFileName();
     $container->get('runner')->willReturn($runner);
     $container->get('logger')->willReturn($logger);
     $container->get('plugins.phpspec')->willReturn($plugin);
     $runner->run(Argument::any())->willReturn($process);
     $runner->setContainer($container);
     $plugin->getOptions()->willReturn(array('cli' => '--some-options', 'all_after_pass' => false, 'keep_failed' => true, 'run_all' => array('cli' => 'run-all')));
     $this->setContainer($container);
     $this->setLogger($logger);
 }
Exemplo n.º 7
0
 function it_should_reload_when_configuration_changed(ContainerInterface $container, ChangeSetEvent $event, EventDispatcherInterface $dispatcher, ConsoleHandler $handler, Logger $logger)
 {
     $container->getParameter('config.file', Argument::any())->shouldBeCalled()->willReturn('phpguard.yml.dist');
     $container->get('logger.handler')->willReturn($handler);
     $container->get('logger')->willReturn($logger);
     $event->getFiles()->willReturn(array('phpguard.yml.dist'));
     $dispatcher->dispatch(ConfigEvents::RELOAD, Argument::any())->shouldBeCalled();
     $dispatcher->dispatch(ApplicationEvents::preEvaluate, Argument::any())->shouldBeCalled();
     $dispatcher->dispatch(ApplicationEvents::evaluate, Argument::any())->shouldBeCalled();
     $dispatcher->dispatch(ApplicationEvents::postEvaluate, Argument::any())->shouldBeCalled();
     $this->listen($event);
 }
Exemplo n.º 8
0
 function let(ContainerInterface $container, Logger $logger, Locator $locator, Inspector $inspector, Application $application)
 {
     $container->get('locator')->willReturn($locator);
     $container->get('phpspec.inspector')->willReturn($inspector);
     $container->get('ui.application')->willReturn($application);
     $container->getParameter('filter.tags', Argument::any())->willReturn(array());
     $container->getParameter('phpspec.suites', Argument::any())->willReturn(array());
     // initialize default options
     $this->setOptions(array());
     $container->get('logger')->willReturn($logger);
     $this->setContainer($container);
     $this->setLogger($logger);
 }
Exemplo n.º 9
0
 function let(ContainerInterface $container, OutputInterface $output, ConsoleHandler $handler)
 {
     Filesystem::create()->mkdir(self::$tmpDir);
     $container->get('logger.handler')->willReturn($handler);
     $this->setContainer($container);
     $container->get('ui.output')->willReturn($output);
     $container->getParameter('phpguard.use_tty', Argument::any())->willReturn(false);
 }
Exemplo n.º 10
0
 /**
  * @codeCoverageIgnore
  */
 public function exitApplication()
 {
     $exitCode = $this->container->getParameter('application.exit_code', 0);
     $type = ResultEvent::$maps[$exitCode];
     $this->container->get('logger')->addCommon('Application exit with code: <highlight>' . $exitCode . ' - ' . $type . '</highlight>');
     $this->container->get('ui.output')->writeln('');
     $this->container->get('logger')->addCommon(PhpGuard::EXIT_MESSAGE);
     $this->container->get('ui.output')->writeln('');
     exit($exitCode);
 }
Exemplo n.º 11
0
 function let(ContainerInterface $container, Runner $runner, Process $process, BehatPlugin $plugin, Filesystem $filesystem)
 {
     if (is_null(static::$cwd)) {
         static::$cwd = getcwd();
     }
     if (!is_dir(static::$tmpDir)) {
         mkdir(static::$tmpDir, 0777, true);
     }
     chdir(static::$tmpDir);
     $container->get('plugins.behat')->willReturn($plugin);
     $container->get('runner')->willReturn($runner);
     $this->options = array('all_after_pass' => false, 'cli' => 'run_cli', 'run_all_cli' => 'run_all_cli', 'executable' => 'executable');
     $plugin->getOptions()->willReturn($this->options);
     $runner->run(Argument::any())->willReturn($process);
     $filesystem->pathExists(Inspector::getRerunFileName())->willReturn(false);
     $container->get('filesystem')->willReturn($filesystem);
     $this->rerunFile = Inspector::getRerunFileName();
     $this->setContainer($container);
 }
Exemplo n.º 12
0
 private function loadPlugin(ContainerInterface $container, $class)
 {
     if (class_exists($class)) {
         $r = new \ReflectionClass($class);
         if (!$r->isAbstract()) {
             $plugin = new $class();
             $id = 'plugins.' . $plugin->getName();
             if (!$container->has($id)) {
                 $logger = new Logger($plugin->getTitle());
                 $logger->pushHandler($container->get('logger.handler'));
                 $plugin->setLogger($logger);
                 $plugin->setContainer($container);
                 $container->set($id, $plugin);
                 $container->get('dispatcher')->addSubscriber($plugin);
             }
         }
     }
 }
Exemplo n.º 13
0
 /**
  * @param  false|string $command
  * @return int
  */
 public function runCommand($command)
 {
     if ($command == false) {
         $command = 'all';
     }
     $command = trim($command);
     if ($command == 'quit') {
         $event = new GenericEvent($this->container);
         $this->container->get('dispatcher')->dispatch(ApplicationEvents::terminated, $event);
     } else {
         $this->unsetStreamBlocking();
         $this->readlineWriteHistory($command);
         $input = new StringInput($command);
         $retVal = $this->application->run($input, $this->output);
         $this->setStreamBlocking();
         $this->showPrompt();
         return $retVal;
     }
 }
Exemplo n.º 14
0
 function let(ContainerInterface $container, PluginInterface $plugin, EventDispatcherInterface $dispatcher, Shell $shell, PhpGuard $phpGuard, OutputInterface $output, Logger $logger, ConsoleHandler $handler)
 {
     $container->getByPrefix('plugins')->willReturn(array($plugin));
     $container->get('dispatcher')->willReturn($dispatcher);
     $container->get('ui.shell')->willReturn($shell);
     $container->get('ui.output')->willReturn($output);
     $container->get('phpguard')->willReturn($phpGuard);
     $container->get('logger')->willReturn($logger);
     $container->get('logger.handler')->willReturn($handler);
     $container->getParameter('config.file')->willReturn('config_file');
     $container->setParameter(Argument::cetera())->willReturn(true);
     $plugin->isActive()->willReturn(true);
     $plugin->getName()->willReturn('some');
     $this->setContainer($container);
 }
Exemplo n.º 15
0
    function it_should_process_plugin_section(ContainerInterface $container, PluginInterface $pspec, PluginInterface $plugin)
    {
        $container->has('plugins.phpspec')->willReturn(true);
        $container->get('plugins.phpspec')->willReturn($plugin);
        $plugin->setOptions(array('all_on_success' => true, 'formatter' => 'progress', 'ansi' => true))->shouldBeCalled();
        $plugin->addWatcher(Argument::any())->shouldBeCalled();
        $plugin->setActive(true)->shouldBeCalled();
        $text = <<<EOF

phpspec:
    options:
        all_on_success: true
        formatter: progress
        ansi: true
    watch:
        - { pattern: "#^spec\\/.*\\.php\$#" }
        - { pattern: "#^src\\/.*\\.php\$#" }

EOF;
        touch($file = self::$tmpDir . '/test.yml');
        file_put_contents($file, $text, LOCK_EX);
        $this->compileFile($file);
    }
Exemplo n.º 16
0
 function it_should_set_code_coverage_from_container(ContainerInterface $container)
 {
     $container->get('coverage')->shouldBeCalled();
     $container->get('coverage.filter')->shouldBeCalled();
     $this->setContainer($container);
 }
Exemplo n.º 17
0
 /**
  * @return ApplicationTester
  */
 protected function getTester()
 {
     return static::$container->get('tester');
 }
Exemplo n.º 18
0
 function let(ContainerInterface $container, Logger $logger)
 {
     $container->get('logger')->willReturn($logger);
     $container->has(Argument::any())->willReturn(true);
     $this->setContainer($container);
 }
Exemplo n.º 19
0
 function it_should_reload_configuration(GenericEvent $event, ContainerInterface $container, EventDispatcherInterface $dispatcher, Processor $processor)
 {
     $configFile = getcwd() . '/phpguard.yml.dist';
     $container->get('config')->shouldBeCalled()->willReturn($processor);
     $container->getParameter('config.file')->shouldBeCalled()->willReturn($configFile);
     $dispatcher->dispatch(ConfigEvents::PRELOAD, $event)->shouldBeCalled();
     $processor->compileFile($configFile)->shouldBeCalled();
     $dispatcher->dispatch(ConfigEvents::POSTLOAD, $event)->shouldBeCalled();
     $this->reload($event, ConfigEvents::LOAD, $dispatcher);
 }
Exemplo n.º 20
0
 function it_should_check_file_with_linter_if_defined(ContainerInterface $container, LinterInterface $linter)
 {
     $container->has('linters.some')->shouldBeCalled()->willReturn(true);
     $container->get('linters.some')->willReturn($linter);
     $linter->getName()->shouldBeCalled()->willReturn('some');
     $linter->getTitle()->willReturn('SomeTitle');
     $this->setOptions(array('lint' => 'some', 'pattern' => 'some'));
     $linter->check(__FILE__)->shouldBeCalled()->willReturn(true);
     $this->lint(__FILE__)->shouldReturn(true);
 }