Inheritance: extends Symfony\Component\Console\Command\Command, use trait Peridot\Core\HasEventEmitterTrait
示例#1
0
                assert($reporter == 'test', 'reporter name should be "test"');
            });
        });
        it('should emit a load event', function () {
            $command = null;
            $config = null;
            $this->emitter->on('peridot.load', function ($cmd, $cfg) use(&$command, &$config) {
                $command = $cmd;
                $config = $cfg;
            });
            $this->command->run(new ArrayInput([], $this->definition), $this->output);
            assert($command === $this->command, "command should have been received by event");
            assert($config === $this->configuration, "configuration should have been received by event");
        });
        context('when there are failing tests', function () {
            it('should return an exit code', function () {
                $suite = new Suite("fail suite", function () {
                });
                $test = new Test('fail', function () {
                    throw new Exception('fail');
                });
                $suite->addTest($test);
                $runner = new Runner($suite, $this->configuration, $this->emitter);
                $command = new Command($runner, $this->configuration, $this->factory, $this->emitter);
                $command->setApplication($this->application);
                $exit = $command->run(new ArrayInput([], $this->definition), $this->output);
                assert($exit == 1, "exit code should be 1");
            });
        });
    });
});
 /**
  * Configure the Peridot command for concurrency. Sets the runner to a concurrency runner,
  * and sets the suite loader to a concurrency suite loader.
  *
  * @param Command $command
  * @return void
  */
 protected function configureCommand(Command $command)
 {
     $broker = new MessageBroker();
     $pool = new WorkerPool($this->getConfiguration(), $this->emitter, $broker);
     $runner = new StreamSelectRunner($this->emitter, $pool);
     $command->setRunner($runner);
     $loader = new SuiteLoader($this->getConfiguration()->getGrep(), $this->emitter);
     $command->setLoader($loader);
 }