コード例 #1
0
 public function testCmd()
 {
     $fileQueue = new FileQueueProvider(null);
     $fileQueue->push('null');
     $fileQueue->push('null1');
     $fileQueue->push('null2');
     $cmd = new LightQueueCommand();
     $this->setExpectedException('Ark4ne\\LightQueue\\Exception\\LightQueueException', 'LightQueueCommand data invalid');
     $this->assertEquals(0, $cmd->run(new IConsole(), new OConsole()));
     $this->assertEquals(2, $fileQueue->queueSize());
     $this->assertEquals('null1', $fileQueue->next());
     $this->assertEquals(1, $fileQueue->queueSize());
     $this->assertEquals('null2', $fileQueue->next());
     $this->assertFalse($fileQueue->hasNext());
 }
コード例 #2
0
 public function testFileLockException()
 {
     $file = new \Ark4ne\LightQueue\Provider\FileLockable(Config::get('queue.lightqueue.queue_directory') . md5('testFileLockException') . ".queue");
     $queue = new FileQueueProvider('testFileLockException');
     $file->handle();
     $this->assertEquals($queue->getFile()->getPath(), $file->getPath());
     $this->assertTrue($file->lock());
     $this->assertFalse($queue->push('test'));
     $this->assertTrue($file->unlock());
     $this->assertTrue($queue->push('test'));
     $this->assertTrue($file->lock());
     $this->assertNull($queue->next());
     $this->assertTrue($file->unlock());
     $this->assertNotNull($queue->next());
 }