/** * Check that we can get the information of a task * * @return void * * @test */ public function testGetTaskInformation() { //generate a random value to verify $_testValue = mt_rand(); //create a task and check it's instantiated $_task = $this->_getTask($_testValue); //add task to queue $this->_adapter->addTask($this->_queue, $_task); //reserve a queue task $_task2 = $this->_adapter->getTask($this->_queue->getName()); //check that the data is as expected $this->assertEquals($this->_adapter->getInformation($_task2)->getData(), array('queue' => 'unit_tests', 'state' => 'reserved', 'priority' => '1024', 'age' => '0', 'delay' => '0', 'ttr' => '60', 'expiration' => '59', 'reserves' => '1', 'timeouts' => '0', 'releases' => '0', 'holds' => '0', 'unholds' => '0'), 'Check that the task information is as we expected'); //delete the task that was set $this->_adapter->remove($this->_queue, $_task2); }
/** * Can we extend the expiration time for the task * * @return void * * @test */ public function testTouch() { //generate a random value to verify $_testValue = mt_rand(); //create a task and check it's instantiated $_task = $this->_getTask($_testValue); //add task to queue $this->_adapter->addTask($this->_queue, $_task); //reserve a queue task $_task2 = $this->_adapter->getTask($this->_queue->getName()); //sleep for 5 seconds to allow the time-left to tick down sleep(5); //get the time-left prior to touching it $_timeLeft1 = $_task2->getInfo(true)->getExpiration(); //touch the task $_task2->touch(); //get the time-left post touch $_timeLeft2 = $_task2->getInfo(true)->getExpiration(); //get the information for the task $this->assertGreaterThanOrEqual($_timeLeft1, $_timeLeft2, 'Check that the expiration has been updated'); //delete the task that was set $this->_adapter->remove($this->_queue, $_task2); }