示例#1
0
 public function testAssignment()
 {
     $action = $this->createIndexAction()->addEventListener(Event\Type\Dummy::toType(), function () {
         $this->startTransaction = true;
         return $this->startTransaction;
     });
     $event = $action->dispatch(Event\Type\Dummy::create());
     $this->assertTrue($event->getResult());
 }
示例#2
0
 public function setUp()
 {
     $autoloader = (require __DIR__ . '/../../vendor/autoload.php');
     $this->appPkg = Application::create($autoloader)->addExtension(__DIR__ . '/../..')->bootstrap(Event\Type\Dummy::create());
 }
示例#3
0
 /**
  * @return $this
  */
 public function run(InputInterface $input = null, OutputInterface $output = null)
 {
     if (null === $input) {
         $this->input = new ArgvInput();
     }
     if (null === $output) {
         $this->output = new ConsoleOutput();
     }
     $className = $this->getCommandClassName($this->input);
     if (class_exists($className)) {
         $this->commandName = $this->getCommandName($this->input);
         $this->commandInstance = $className::create($this->commandName);
         $this->commandInstance->setApplication($this);
         $this->add($this->commandInstance);
     } else {
         $commandEvent = Event\Type\Dummy::create();
     }
     // Dispatch event
     $cliArgsContainer = new Container('cliArgsContainer');
     if ($this->input->hasParameterOption('--env')) {
         $cliArgsContainer->set('env', $this->input->getParameterOption('--env'));
     }
     $commandEvent = CommandEvent::create($this, $cliArgsContainer);
     $this->application->dispatch($commandEvent);
     // Run command
     if ($commandEvent->getStatus() != Event\STATUS_DISCARDED) {
         $this->doRun($this->input, $this->output);
     }
 }