/** * Check that we can queue multiple tasks, hold them, and then unhold them all * * @return void * * @test */ public function testMultipleUnhold() { //number of tasks to work with $_taskCount = 5; $_tasks = array(); //create and queue the tasks for ($i = 0; $i < $_taskCount; $i++) { //add and then retrieve the task $this->_queue->addTask($this->_getTask(self::DEFAULT_TASK_DATA, 'test_error')); $_tasks[$i] = $this->_queue->getNextUnreservedTask(); //run the tasks $this->_queue->runNextTask(); //check it's been held $this->assertEquals(Lilmuckers_Queue_Model_Queue_Task_State::HELD, $_tasks[$i]->getInfo(true)->getState(), 'Check that the task was held'); } // multiple unholds $this->_adapter->unholdMultiple(10); //create and queue the tasks for ($i = 0; $i < $_taskCount; $i++) { //check it's been held $this->assertEquals(Lilmuckers_Queue_Model_Queue_Task_State::QUEUED, $_tasks[$i]->getInfo(true)->getState(), 'Check that the task was unheld'); //remove the task $this->_queue->remove($_tasks[$i]); } }
/** * Test that we can get an unreserved task * * @return void * * @test */ public function testGetUnreservedTask() { //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); //peek at queue task $_task2 = $this->_adapter->getUnreservedTask($this->_queue); //get the info on the task and check that it's still queued $this->assertEquals(Lilmuckers_Queue_Model_Queue_Task_State::QUEUED, $_task2->getInfo(true)->getState(), 'Check that the task was requeued'); //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); }