public function testGetJobState() { $this->reset(); $obj = new StateManager(__DIR__ . '/testbench/phpprog.json'); $this->assertEquals($obj->getJobState(0)['ha'], 'haha'); $state = $obj->getJobState(1); $this->assertEquals($state['he'], 'hehe'); $this->assertNull($state['vars']['some_var']); $state['vars']['some_var'] = 'some_val'; $obj->setJobState(1, $state); $this->assertEquals($obj->getJobState(1)['vars']['some_var'], 'some_val'); $this->assertEquals($obj->getJobState(1)['he'], 'hehe'); }
public function __construct($jid) { if (!is_int($jid)) { throw new \InvalidArgumentException('Job constructor arguments type error'); } $this->jid = $jid; $this->manager = $manager = new StateManager(); $this->period = $manager->getJobPeriod($jid); $this->state = $state = $manager->getJobState($jid); StateManager::completeKeys($state, static::$vars); $this->lastRun = $state['last_run']; }