Example #1
0
 /**
  * Start the console application
  * 
  * @return int 0 if everything went fine, or an error code
  */
 public function run()
 {
     $this->configuration->apply($this->injector);
     $application = $this->injector->make(ConsoleApplication::class);
     array_map(function ($command) use($application) {
         $application->add($this->injector->make($command));
     }, $this->commands->toArray());
     return $application->run();
 }
Example #2
0
 public function testRun()
 {
     $application = $this->getMockBuilder(ConsoleApplication::class)->setMethods(['run', 'add'])->getMock();
     $application->expects($this->once())->method('run');
     $application->expects($this->once())->method('add')->with(new Hello());
     $this->configuration->expects($this->once())->method('apply')->with($this->injector);
     $this->injector->expects($this->exactly(2))->method('make')->will($this->onConsecutiveCalls($application, new Hello()));
     $this->commands->expects($this->any())->method('toArray')->willReturn([Hello::class]);
     Application::build($this->injector, $this->configuration, $this->commands)->run();
 }