diff --git a/src/UglyQueue.php b/src/UglyQueue.php index 78b82c3..fbd0333 100644 --- a/src/UglyQueue.php +++ b/src/UglyQueue.php @@ -361,7 +361,23 @@ HTML; */ public function queueExists($groupName) { - return (bool)is_dir($this->getQueueBaseDir().$groupName); + return (bool)is_dir($this->queueBaseDir.$groupName); + } + + /** + * @return array + */ + public function getInitializedQueueList() + { + $queueList = array(); + foreach(glob(realpath($this->queueBaseDir).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR) as $queueDir) + { + $exp = explode(DIRECTORY_SEPARATOR, $queueDir); + $dir = end($exp); + if (strpos($dir, '.') !== 0) + $queueList[] = $dir; + } + return $queueList; } /** diff --git a/tests/UglyQueue/UglyQueueTest.php b/tests/UglyQueue/UglyQueueTest.php index 45195ca..c12ee9b 100644 --- a/tests/UglyQueue/UglyQueueTest.php +++ b/tests/UglyQueue/UglyQueueTest.php @@ -656,4 +656,18 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase $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); + } } \ No newline at end of file