/** * Checks if a command is pre-defined. * * @return void * @author Dan Cox */ public function hasDefinition(array $commands) { $cmd = $commands[0]; if (ProcessDefinition::has($cmd)) { $pName = ProcessDefinition::get($cmd); $process = $this->DI->get($pName); unset($commands[0]); $process->build(['directory' => $this->input->getArgument('directory')]); if (!empty($commands)) { $process->setArguments(array_values($commands)); } $p = $process->getProcess(); return $p; } return false; }
/** * Check a single command for a definition in processes * * @return Process * @author Dan Cox */ public function hasProcessDefinition($command) { $cmds = explode(' ', $command); if (ProcessDefinition::has($cmds[0])) { $name = ProcessDefinition::get($cmds[0]); $process = $this->DI->get($name); unset($cmds[0]); $process->build($this->params); if (!empty($cmds)) { $process->setArguments(array_values($cmds)); } return $process->getProcess(); } // If theres no definition, build a skeleton $process = $this->DI->get('skeletonprocess'); $process->build($this->params); return $process->setArguments($cmds)->getProcess(); }
/** * Now we have a definition, check the static method works * * @return void * @author Dan Cox */ public function test_getStatic() { $this->assertTrue(ProcessDefinition::has('cmd')); $this->assertEquals($this->processMock, ProcessDefinition::get('cmd')); }
/** * Test the definition returns the correct process * * @return void * @author Dan Cox */ public function test_definition() { $this->assertTrue(ProcessDefinition::has('ls')); $this->assertEquals('listprocess', ProcessDefinition::get('ls')); }
/** * Test the definition * * @return void * @author Dan Cox */ public function test_definition() { $this->assertTrue(ProcessDefinition::has('composer')); $this->assertEquals('composerprocess', ProcessDefinition::get('composer')); $this->assertFalse(ProcessDefinition::has('fake')); $this->assertFalse(ProcessDefinition::get('fake')); }