2014-09-29 17:02:28 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class UglyQueueManagerTest
|
|
|
|
|
*/
|
|
|
|
|
class UglyQueueManagerTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
2015-09-29 11:35:48 -05:00
|
|
|
protected $baseDir;
|
|
|
|
|
|
2014-10-01 08:10:39 -05:00
|
|
|
protected $reallyTastySandwich = array(
|
|
|
|
|
'0' => 'beef broth',
|
|
|
|
|
'1' => 'barbeque sauce',
|
|
|
|
|
'2' => 'boneless pork ribs',
|
|
|
|
|
);
|
|
|
|
|
|
2015-09-29 11:35:48 -05:00
|
|
|
protected function setUp()
|
|
|
|
|
{
|
|
|
|
|
$this->baseDir = __DIR__.'/../misc/queues';
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 17:18:14 -05:00
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::__construct
|
|
|
|
|
* @covers \DCarbone\UglyQueue::unserialize
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::addQueue
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::containsQueueWithName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
|
|
|
|
* @uses \DCarbone\UglyQueue
|
|
|
|
|
* @return \DCarbone\UglyQueueManager
|
|
|
|
|
*/
|
2015-09-29 11:35:48 -05:00
|
|
|
public function testCanInitializeObjectWithValidPath()
|
2014-09-29 17:18:14 -05:00
|
|
|
{
|
2015-09-29 11:35:48 -05:00
|
|
|
$manager = new \DCarbone\UglyQueueManager($this->baseDir);
|
2014-09-29 17:18:14 -05:00
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\\DCarbone\\UglyQueueManager', $manager);
|
|
|
|
|
|
|
|
|
|
return $manager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::__construct
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
|
|
|
|
* @expectedException \RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
public function testExceptionThrownDuringConstructionWithInvalidBasePathValue()
|
|
|
|
|
{
|
2015-09-29 11:35:48 -05:00
|
|
|
new \DCarbone\UglyQueueManager('i do not exist!');
|
2014-09-29 17:18:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-29 17:23:43 -05:00
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::containsQueueWithName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-09-29 17:23:43 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testCanDetermineIfValidQueueExistsInManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$shouldBeTrue = $manager->containsQueueWithName('tasty-sandwich');
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($shouldBeTrue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::containsQueueWithName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-09-29 17:23:43 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testCanDetermineQueueDoesNotExistInManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$shouldBeFalse = $manager->containsQueueWithName('i should not exist');
|
|
|
|
|
|
|
|
|
|
$this->assertFalse($shouldBeFalse);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 08:10:39 -05:00
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::getQueueWithName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
|
|
|
|
* @uses \DCarbone\UglyQueue
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-10-01 08:10:39 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testCanGetUglyQueueObjectFromManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$uglyQueue = $manager->getQueueWithName('tasty-sandwich');
|
|
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\\DCarbone\\UglyQueue', $uglyQueue);
|
2015-09-29 11:35:48 -05:00
|
|
|
$this->assertEquals('tasty-sandwich', $uglyQueue->getName());
|
2014-10-01 08:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::getQueueWithName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
|
|
|
|
* @expectedException \InvalidArgumentException
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-10-01 08:10:39 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testExceptionThrownWhenTryingToGetNonExistentQueueFromManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
2015-09-29 11:35:48 -05:00
|
|
|
$manager->getQueueWithName('sandwiches');
|
2014-10-01 08:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::getQueueList
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-10-01 08:10:39 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testCanGetListOfQueuesInManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$queueList = $manager->getQueueList();
|
|
|
|
|
|
|
|
|
|
$this->assertInternalType('array', $queueList);
|
|
|
|
|
$this->assertCount(1, $queueList);
|
|
|
|
|
$this->assertContains('tasty-sandwich', $queueList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::getQueueWithName
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::addQueue
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
|
|
|
|
* @uses \DCarbone\UglyQueue
|
|
|
|
|
* @expectedException \RuntimeException
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-10-01 08:10:39 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testExceptionThrownWhenReAddingQueueToManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$uglyQueue = $manager->getQueueWithName('tasty-sandwich');
|
|
|
|
|
|
|
|
|
|
$manager->addQueue($uglyQueue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::addQueueAtPath
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::addQueue
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::getQueueWithName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
|
|
|
|
* @uses \DCarbone\UglyQueue
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-10-01 08:10:39 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testCanInitializeNewQueueAndAddToManager(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$manager->addQueueAtPath(__DIR__.'/../misc/queues/really-tasty-sandwich');
|
|
|
|
|
|
|
|
|
|
$uglyQueue = $manager->getQueueWithName('really-tasty-sandwich');
|
|
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\\DCarbone\\UglyQueue', $uglyQueue);
|
2015-09-29 11:35:48 -05:00
|
|
|
$this->assertEquals('really-tasty-sandwich', $uglyQueue->getName());
|
2014-10-01 08:10:39 -05:00
|
|
|
|
|
|
|
|
$queueList = $manager->getQueueList();
|
|
|
|
|
|
|
|
|
|
$this->assertInternalType('array', $queueList);
|
|
|
|
|
$this->assertCount(2, $queueList);
|
|
|
|
|
$this->assertContains('really-tasty-sandwich', $queueList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \DCarbone\UglyQueueManager::removeQueueByName
|
|
|
|
|
* @uses \DCarbone\UglyQueueManager
|
2015-09-29 11:35:48 -05:00
|
|
|
* @depends testCanInitializeObjectWithValidPath
|
2014-10-01 08:10:39 -05:00
|
|
|
* @param \DCarbone\UglyQueueManager $manager
|
|
|
|
|
*/
|
|
|
|
|
public function testCanRemoveQueueFromManagerByName(\DCarbone\UglyQueueManager $manager)
|
|
|
|
|
{
|
|
|
|
|
$manager->removeQueueByName('really-tasty-sandwich');
|
|
|
|
|
|
|
|
|
|
$queueList = $manager->getQueueList();
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $queueList);
|
|
|
|
|
$this->assertNotContains('really-tasty-sandwich', $queueList);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 17:02:28 -05:00
|
|
|
// /**
|
|
|
|
|
// * @covers \DCarbone\UglyQueue::queueExists
|
|
|
|
|
// * @uses \DCarbone\UglyQueue
|
|
|
|
|
// * @depends testCanInitializeNewUglyQueue
|
|
|
|
|
// * @param \DCarbone\UglyQueue $uglyQueue
|
|
|
|
|
// */
|
|
|
|
|
// public function testCanDetermineExistenceOfExistingQueue(\DCarbone\UglyQueue $uglyQueue)
|
|
|
|
|
// {
|
|
|
|
|
// $exists = $uglyQueue->queueExists('tasty-sandwich');
|
|
|
|
|
//
|
|
|
|
|
// $this->assertTrue($exists);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * @covers \DCarbone\UglyQueue::queueExists
|
|
|
|
|
// * @uses \DCarbone\UglyQueue
|
|
|
|
|
// * @depends testCanInitializeNewUglyQueue
|
|
|
|
|
// * @param \DCarbone\UglyQueue $uglyQueue
|
|
|
|
|
// */
|
|
|
|
|
// public function testCanDetermineExistenceOfNonExistingQueue(\DCarbone\UglyQueue $uglyQueue)
|
|
|
|
|
// {
|
|
|
|
|
// $exists = $uglyQueue->queueExists('nasty-sandwich');
|
|
|
|
|
//
|
|
|
|
|
// $this->assertFalse($exists);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * @covers \DCarbone\UglyQueue::getInitializedQueueList
|
|
|
|
|
// * @uses \DCarbone\UglyQueue
|
|
|
|
|
// * @depends testCanInitializeNewUglyQueue
|
|
|
|
|
// * @param \DCarbone\UglyQueue $uglyQueue
|
|
|
|
|
// */
|
|
|
|
|
// public function testCanGetListOfInitializedQueues(\DCarbone\UglyQueue $uglyQueue)
|
|
|
|
|
// {
|
|
|
|
|
// $queueList = $uglyQueue->getInitializedQueueList();
|
|
|
|
|
//
|
|
|
|
|
// $this->assertEquals(1, count($queueList));
|
|
|
|
|
// $this->assertContains('tasty-sandwich', $queueList);
|
|
|
|
|
// }
|
|
|
|
|
}
|