function before()
 {
     $this->access = Mockster::of(AccessControl::class);
     $this->registry = new ActionRegistry();
     $this->registry->restrictAccess(Mockster::mock($this->access));
     $this->reader = Mockster::of(ParameterReader::class);
     $fields = new FieldRegistry();
     $this->executor = new Executor($this->registry, $fields, Mockster::mock(RendererRegistry::class), Mockster::mock($this->reader));
     $this->executor->restrictAccess(Mockster::mock($this->access));
     $fields->add(new StringField());
 }
Пример #2
0
 private function doRun(Console $console)
 {
     $outFile = null;
     if ($console->getArguments()) {
         if ($console->getArguments()[0] == self::INTERACTIVE_MODE) {
             $outFile = $console->getOption('out', null);
             $actionId = $this->selectAction($console);
             $reader = new InteractiveCliParameterReader($this->fields, $console);
             $this->printActionHeader($console, $actionId);
         } else {
             $actionId = $console->getArguments()[0];
             $reader = new CliParameterReader($console);
         }
     } else {
         $this->printUsage($console);
         $this->printActions($console);
         return self::OK;
     }
     $this->registerFields($reader);
     $this->registerRenderers();
     $executor = new Executor($this->actions, $this->fields, $reader, $this->access);
     return $this->printResult($console, $executor->execute($actionId), $outFile);
 }
Пример #3
0
 private function whenIExecute_With($id, $params)
 {
     $fields = new FieldRegistry();
     foreach ($this->fields as $field) {
         $fields->add(Mockster::mock($field));
     }
     $reader = new FakeParameterReader($params);
     $executor = new Executor($this->action->registry, $fields, $reader, $this->access);
     $this->result = $executor->execute($id);
 }
Пример #4
0
 private function doRun(Console $console)
 {
     if ($console->getArguments()) {
         if ($console->getArguments()[0] == '!') {
             $actionId = $this->selectAction($console);
             $reader = new InteractiveCliParameterReader($this->fields, $console);
             $this->printActionHeader($console, $actionId);
         } else {
             $actionId = $console->getArguments()[0];
             $reader = new CliParameterReader($console);
         }
     } else {
         $this->printUsage($console);
         $this->printActions($console);
         return self::OK;
     }
     $this->registerFields($reader);
     $this->registerRenderers();
     $executor = new Executor($this->actions, $this->fields, $this->renderers, $reader);
     return $this->printResult($console, $executor->execute($actionId));
 }
Пример #5
0
 private function whenIExecute($id)
 {
     $fields = new FieldRegistry();
     foreach ($this->fields as $field) {
         $fields->add(Mockster::mock($field));
     }
     $renderers = new RendererRegistry();
     foreach ($this->renderers as $renderer) {
         $renderers->add(Mockster::mock($renderer));
     }
     $executor = new Executor($this->action->registry, $fields, $renderers, Mockster::mock($this->reader));
     $this->result = $executor->execute($id);
 }
Пример #6
0
 private function execute()
 {
     $result = $this->executor->execute($this->actionId);
     $this->model = ['error' => null, 'missing' => null, 'success' => null, 'redirect' => null, 'output' => null];
     call_user_func([$this, 'handle' . (new \ReflectionClass($result))->getShortName()], $result);
 }