/** * @covers \Qutee\Task::__sleep */ public function testSerializingAndUnserializingTask() { $data = array('test' => 'data'); $this->object->setName('TestTask'); $this->object->setData($data); $this->object->setMethodName('methodName'); $this->object->setPriority(Task::PRIORITY_HIGH); $this->object->setUniqueId('SomeUniqueId'); $serialized = serialize($this->object); $unserialized = unserialize($serialized); $this->assertInstanceOf('\\Qutee\\Task', $unserialized); $this->assertEquals('TestTask', $unserialized->getName()); $this->assertEquals('methodName', $unserialized->getMethodName()); $this->assertSame($data, $unserialized->getData()); $this->assertEquals(3, $unserialized->getPriority()); $this->assertTrue($unserialized->isUnique()); $this->assertEquals(md5('TestTaskSomeUniqueId'), $unserialized->getUniqueId()); }
/** * @covers \Qutee\Queue::getTasks */ public function testGettingTasksQueriesGivenPriority() { $task1 = new Task('task1'); $task1->setPriority(Task::PRIORITY_HIGH); $task2 = new Task('task2'); $task2->setPriority(Task::PRIORITY_LOW); $this->object->addTask($task1)->addTask($task2); $outputTasks = $this->object->getTasks(Task::PRIORITY_LOW); $this->assertTrue(count($outputTasks) == 1); $outputTask = reset($outputTasks); $this->assertEquals($outputTask->getName(), $task2->getName()); }