/** */ public function testExecute() { // Set directory of tasks $path = PHIGRATE_BASE . '/library/Task'; $this->object->setDirectoryOfTasks($path, true); $task = new taskMock(); $taskName = 'my:task'; $this->object->registerTask($taskName, $task); $this->assertTrue($this->object->hasTask($taskName)); $this->assertInstanceOf('Phigrate_Task_ITask', $this->object->getTask($taskName)); $args = array('test' => 'value', 'get' => 'task', 'execute' => 'manager'); $return = $this->object->execute($taskName, $args); $this->assertInternalType('string', $return); $expected = 'taskMock::execute: ' . implode(', ', $args); $this->assertEquals($expected, $return); }
/** * execute * * @return void */ public function execute() { $this->_logger->debug(__METHOD__ . ' Start'); $output = ''; if ($this->_curTaskName != 'db:export') { $output = $this->_getHeaderScript(); } if ($this->_taskMgr->hasTask($this->_curTaskName)) { if ($this->_helpTask) { $output .= $this->_taskMgr->help($this->_curTaskName); } else { $output .= $this->_taskMgr->execute($this->_curTaskName, $this->_taskOptions); } } else { $msg = 'Task not found: ' . $this->_curTaskName; $this->_logger->err($msg); require_once 'Phigrate/Exception/InvalidTask.php'; throw new Phigrate_Exception_InvalidTask($msg); } $this->_logger->debug(__METHOD__ . ' End'); return $output; }