public function testFactoryByIdMethod() { $job = new TestAction(); $job->insert(); $newJob = Job::factoryById($job->id->getValue()); $this->AssertEquals(get_class($job), get_class($newJob)); }
protected function action() { $job = Job::factoryById($this->getParam('id')); if ($job->status->getValue() != Job::NewStatus) { return; } $job->status = Job::CanceledStatus; $job->update(); }
public function testAdd() { $fixture = 'hello world!'; $api = new Add(['class' => TestAction::ModelName, 'actionDate' => '', 'hash' => $fixture]); $id = $api->exec(); $new = Job::factoryById($id); $this->assertEquals($new->status->getValue(), TestAction::NewStatus); $this->assertEquals($new->class->getValue(), TestAction::ModelName); $this->assertEquals($new->hash->getValue(), $fixture); }
protected function action() { $originalJob = \Extasy\Schedule\Job::factoryById($this->getParam('id')); if (Job::NewStatus == $originalJob->status->getValue()) { return $originalJob->id->getValue(); } $className = get_class($originalJob); $job = new $className(); $job->hash = $originalJob->hash->getValue(); $job->actionDate->setTime($this->getParam('actionDate')); $job->data = $originalJob->data->getValue(); $job->insert(); return $job->id->getValue(); }