Example #1
0
 public function testGetAllKeysMethod()
 {
     $c1 = Container::createFromArray(['a' => ['b' => ['c' => 1, 'cc' => 2]]]);
     $c1->set('a.d', 1);
     $this->assertEquals(3, count($c1->getAllKeys()));
     $this->assertEquals('a.b.c', $c1->getAllKeys()[0]);
     $this->assertEquals('a.b.cc', $c1->getAllKeys()[1]);
     $this->assertEquals('a.d', $c1->getAllKeys()[2]);
     $c1->set('a.b', 1);
     $this->assertEquals(2, count($c1->getAllKeys()));
 }
Example #2
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);
     }
 }