You've already forked ugly-queue
First round of updates finished.
This commit is contained in:
@@ -44,6 +44,9 @@ class UglyQueue implements \Serializable, \SplSubject, \Countable
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $lockFile;
|
protected $lockFile;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $serializeFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $baseDir
|
* @param string $baseDir
|
||||||
* @param string $name
|
* @param string $name
|
||||||
@@ -51,27 +54,20 @@ class UglyQueue implements \Serializable, \SplSubject, \Countable
|
|||||||
*/
|
*/
|
||||||
public function __construct($baseDir, $name, array $observers = array())
|
public function __construct($baseDir, $name, array $observers = array())
|
||||||
{
|
{
|
||||||
$this->baseDir = trim($baseDir, "/\\");
|
$this->baseDir = realpath($baseDir);
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->_observers = $observers;
|
$this->_observers = $observers;
|
||||||
|
|
||||||
$path = sprintf('%s/%s', $baseDir, $name);
|
$path = sprintf('%s%s%s', $baseDir, DIRECTORY_SEPARATOR, $name);
|
||||||
if (!file_exists($path) && !@mkdir($path))
|
if (!file_exists($path) && !@mkdir($path))
|
||||||
throw new \RuntimeException('Unable to initialize queue directory "'.$path.'". Please check permissions.');
|
throw new \RuntimeException('Unable to initialize queue directory "'.$path.'". Please check permissions.');
|
||||||
|
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
$this->lockFile = sprintf('%s/queue.lock', $path);
|
$this->lockFile = sprintf('%s%squeue.lock', $path, DIRECTORY_SEPARATOR);
|
||||||
$this->queueFile = sprintf('%s/queue.txt', $path);
|
$this->queueFile = sprintf('%s%squeue.txt', $path, DIRECTORY_SEPARATOR);
|
||||||
$this->queueTmpFile = sprintf('%s/queue.tmp', $path);
|
$this->queueTmpFile = sprintf('%s%squeue.tmp', $path, DIRECTORY_SEPARATOR);
|
||||||
|
$this->serializeFile = sprintf('%s%sugly-queue.obj', $path, DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
$this->_initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize queue if needed.
|
|
||||||
*/
|
|
||||||
private function _initialize()
|
|
||||||
{
|
|
||||||
if (is_readable($this->path) && is_writable($this->path))
|
if (is_readable($this->path) && is_writable($this->path))
|
||||||
$this->mode = self::QUEUE_READWRITE;
|
$this->mode = self::QUEUE_READWRITE;
|
||||||
else if (is_readable($this->path))
|
else if (is_readable($this->path))
|
||||||
@@ -173,6 +169,14 @@ HTML;
|
|||||||
return $this->lockFile;
|
return $this->lockFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSerializeFile()
|
||||||
|
{
|
||||||
|
return $this->serializeFile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $ttl Time to live in seconds
|
* @param int $ttl Time to live in seconds
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
@@ -200,31 +204,6 @@ HTML;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $ttl seconds to live
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function createLockFile($ttl)
|
|
||||||
{
|
|
||||||
$ok = (bool)@file_put_contents(
|
|
||||||
$this->lockFile,
|
|
||||||
json_encode(array('ttl' => $ttl, 'born' => time())));
|
|
||||||
|
|
||||||
if ($ok !== true)
|
|
||||||
{
|
|
||||||
$this->_notifyStatus = UglyQueueEnum::QUEUE_FAILED_TO_LOCK;
|
|
||||||
$this->notify();
|
|
||||||
return $this->locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->locked = true;
|
|
||||||
|
|
||||||
$this->_notifyStatus = UglyQueueEnum::QUEUE_LOCKED;
|
|
||||||
$this->notify();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close this ugly queue, writing out contents to file.
|
* Close this ugly queue, writing out contents to file.
|
||||||
*/
|
*/
|
||||||
@@ -450,7 +429,6 @@ HTML;
|
|||||||
*/
|
*/
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
var_dump($this->queueFile);
|
|
||||||
return (int)FileHelper::getLineCount($this->queueFile);
|
return (int)FileHelper::getLineCount($this->queueFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,4 +503,31 @@ HTML;
|
|||||||
$observer->update($this);
|
$observer->update($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $ttl seconds to live
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function createLockFile($ttl)
|
||||||
|
{
|
||||||
|
$ok = (bool)@file_put_contents(
|
||||||
|
$this->lockFile,
|
||||||
|
json_encode(array('ttl' => $ttl, 'born' => time())));
|
||||||
|
|
||||||
|
if ($ok !== true)
|
||||||
|
{
|
||||||
|
$this->_notifyStatus = UglyQueueEnum::QUEUE_FAILED_TO_LOCK;
|
||||||
|
$this->notify();
|
||||||
|
return $this->locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->locked = true;
|
||||||
|
|
||||||
|
$this->_notifyStatus = UglyQueueEnum::QUEUE_LOCKED;
|
||||||
|
$this->notify();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,6 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanInitializeObjectWithValidParameters()
|
public function testCanInitializeObjectWithValidParameters()
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue = new \DCarbone\UglyQueue($this->baseDir, 'tasty-sandwich');
|
$uglyQueue = new \DCarbone\UglyQueue($this->baseDir, 'tasty-sandwich');
|
||||||
|
|
||||||
$this->assertInstanceOf('\\DCarbone\\UglyQueue', $uglyQueue);
|
$this->assertInstanceOf('\\DCarbone\\UglyQueue', $uglyQueue);
|
||||||
@@ -57,7 +56,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExceptionThrownWhenTryingToProcessQueueAfterInitializationBeforeLock(\DCarbone\UglyQueue $uglyQueue)
|
public function testExceptionThrownWhenTryingToProcessQueueAfterInitializationBeforeLock(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->retrieveItems();
|
$uglyQueue->retrieveItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testKeyExistsInQueueReturnsFalseWithEmptyQueueAfterInitialization(\DCarbone\UglyQueue $uglyQueue)
|
public function testKeyExistsInQueueReturnsFalseWithEmptyQueueAfterInitialization(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$exists = $uglyQueue->keyExistsInQueue(0);
|
$exists = $uglyQueue->keyExistsInQueue(0);
|
||||||
|
|
||||||
$this->assertFalse($exists);
|
$this->assertFalse($exists);
|
||||||
@@ -95,7 +94,6 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanGetQueueDirectory(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanGetQueueDirectory(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$queuePath = $uglyQueue->getPath();
|
$queuePath = $uglyQueue->getPath();
|
||||||
|
|
||||||
$this->assertFileExists($queuePath);
|
$this->assertFileExists($queuePath);
|
||||||
@@ -109,12 +107,107 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanGetQueueName(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanGetQueueName(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$queueName = $uglyQueue->getName();
|
$queueName = $uglyQueue->getName();
|
||||||
|
|
||||||
$this->assertEquals('tasty-sandwich', $queueName);
|
$this->assertEquals('tasty-sandwich', $queueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \DCarbone\UglyQueue::getMode
|
||||||
|
* @depends testCanInitializeObjectWithValidParameters
|
||||||
|
* @param \DCarbone\UglyQueue $uglyQueue
|
||||||
|
*/
|
||||||
|
public function testCanGetQueueMode(\DCarbone\UglyQueue $uglyQueue)
|
||||||
|
{
|
||||||
|
$mode = $uglyQueue->getMode();
|
||||||
|
$this->assertEquals(\DCarbone\UglyQueue::QUEUE_READWRITE, $mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \DCarbone\UglyQueue::getBaseDir
|
||||||
|
* @depends testCanInitializeObjectWithValidParameters
|
||||||
|
* @param \DCarbone\UglyQueue $uglyQueue
|
||||||
|
*/
|
||||||
|
public function testCanGetBaseDirectory(\DCarbone\UglyQueue $uglyQueue)
|
||||||
|
{
|
||||||
|
$baseDir = $uglyQueue->getBaseDir();
|
||||||
|
$this->assertEquals($this->baseDir, $baseDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \DCarbone\UglyQueue::getLockFile
|
||||||
|
* @depends testCanInitializeObjectWithValidParameters
|
||||||
|
* @param \DCarbone\UglyQueue $uglyQueue
|
||||||
|
*/
|
||||||
|
public function testCanGetLockFilePath(\DCarbone\UglyQueue $uglyQueue)
|
||||||
|
{
|
||||||
|
$lockFile = $uglyQueue->getLockFile();
|
||||||
|
$this->assertEquals(
|
||||||
|
sprintf('%s%s%s%squeue.lock',
|
||||||
|
$this->baseDir,
|
||||||
|
DIRECTORY_SEPARATOR,
|
||||||
|
$uglyQueue->getName(),
|
||||||
|
DIRECTORY_SEPARATOR),
|
||||||
|
$lockFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \DCarbone\UglyQueue::getQueueFile
|
||||||
|
* @depends testCanInitializeObjectWithValidParameters
|
||||||
|
* @param \DCarbone\UglyQueue $uglyQueue
|
||||||
|
*/
|
||||||
|
public function testCanGetQueueFilePath(\DCarbone\UglyQueue $uglyQueue)
|
||||||
|
{
|
||||||
|
$queueFile = $uglyQueue->getQueueFile();
|
||||||
|
$this->assertEquals(
|
||||||
|
sprintf('%s%s%s%squeue.txt',
|
||||||
|
$this->baseDir,
|
||||||
|
DIRECTORY_SEPARATOR,
|
||||||
|
$uglyQueue->getName(),
|
||||||
|
DIRECTORY_SEPARATOR),
|
||||||
|
$queueFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \DCarbone\UglyQueue::getQueueTmpFile
|
||||||
|
* @depends testCanInitializeObjectWithValidParameters
|
||||||
|
* @param \DCarbone\UglyQueue $uglyQueue
|
||||||
|
*/
|
||||||
|
public function testCanGetQueueTmpFilePath(\DCarbone\UglyQueue $uglyQueue)
|
||||||
|
{
|
||||||
|
$queueTmpFile = $uglyQueue->getQueueTmpFile();
|
||||||
|
$this->assertEquals(
|
||||||
|
sprintf(
|
||||||
|
'%s%s%s%squeue.tmp',
|
||||||
|
$this->baseDir,
|
||||||
|
DIRECTORY_SEPARATOR,
|
||||||
|
$uglyQueue->getName(),
|
||||||
|
DIRECTORY_SEPARATOR),
|
||||||
|
$queueTmpFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \DCarbone\UglyQueue::getSerializeFile
|
||||||
|
* @depends testCanInitializeObjectWithValidParameters
|
||||||
|
* @param \DCarbone\UglyQueue $uglyQueue
|
||||||
|
*/
|
||||||
|
public function testCanGetSerializeFilePath(\DCarbone\UglyQueue $uglyQueue)
|
||||||
|
{
|
||||||
|
$serializeFile = $uglyQueue->getSerializeFile();
|
||||||
|
$this->assertEquals(
|
||||||
|
sprintf(
|
||||||
|
'%s%s%s%sugly-queue.obj',
|
||||||
|
$this->baseDir,
|
||||||
|
DIRECTORY_SEPARATOR,
|
||||||
|
$uglyQueue->getName(),
|
||||||
|
DIRECTORY_SEPARATOR),
|
||||||
|
$serializeFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \DCarbone\UglyQueue::isLocked
|
* @covers \DCarbone\UglyQueue::isLocked
|
||||||
* @uses \DCarbone\UglyQueue
|
* @uses \DCarbone\UglyQueue
|
||||||
@@ -123,9 +216,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanGetQueueLockedStatus(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanGetQueueLockedStatus(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$locked = $uglyQueue->isLocked();
|
$locked = $uglyQueue->isLocked();
|
||||||
|
|
||||||
$this->assertFalse($locked);
|
$this->assertFalse($locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +228,6 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetQueueItemCountReturnsZeroWithEmptyQueue(\DCarbone\UglyQueue $uglyQueue)
|
public function testGetQueueItemCountReturnsZeroWithEmptyQueue(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$itemCount = count($uglyQueue);
|
$itemCount = count($uglyQueue);
|
||||||
$this->assertEquals(0, $itemCount);
|
$this->assertEquals(0, $itemCount);
|
||||||
}
|
}
|
||||||
@@ -149,7 +239,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanInitializeExistingQueue()
|
public function testCanInitializeExistingQueue()
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue = new \DCarbone\UglyQueue($this->baseDir, 'tasty-sandwich');
|
$uglyQueue = new \DCarbone\UglyQueue($this->baseDir, 'tasty-sandwich');
|
||||||
|
|
||||||
$this->assertInstanceOf('\\DCarbone\\UglyQueue', $uglyQueue);
|
$this->assertInstanceOf('\\DCarbone\\UglyQueue', $uglyQueue);
|
||||||
@@ -166,7 +256,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExceptionThrownWhenPassingNonIntegerValueToLock(\DCarbone\UglyQueue $uglyQueue)
|
public function testExceptionThrownWhenPassingNonIntegerValueToLock(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->lock('7 billion');
|
$uglyQueue->lock('7 billion');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +269,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExceptionThrownWhenPassingNegativeIntegerValueToLock(\DCarbone\UglyQueue $uglyQueue)
|
public function testExceptionThrownWhenPassingNegativeIntegerValueToLock(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->lock(-73);
|
$uglyQueue->lock(-73);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +284,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanLockUglyQueueWithDefaultTTL(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanLockUglyQueueWithDefaultTTL(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$locked = $uglyQueue->lock();
|
$locked = $uglyQueue->lock();
|
||||||
|
|
||||||
$this->assertTrue($locked);
|
$this->assertTrue($locked);
|
||||||
@@ -220,7 +310,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCannotLockQueueThatIsAlreadyLocked(\DCarbone\UglyQueue $uglyQueue)
|
public function testCannotLockQueueThatIsAlreadyLocked(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$lock = $uglyQueue->lock();
|
$lock = $uglyQueue->lock();
|
||||||
|
|
||||||
$this->assertFalse($lock);
|
$this->assertFalse($lock);
|
||||||
@@ -234,7 +324,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsLockedReturnsTrueAfterLocking(\DCarbone\UglyQueue $uglyQueue)
|
public function testIsLockedReturnsTrueAfterLocking(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$isLocked = $uglyQueue->isLocked();
|
$isLocked = $uglyQueue->isLocked();
|
||||||
$this->assertTrue($isLocked);
|
$this->assertTrue($isLocked);
|
||||||
}
|
}
|
||||||
@@ -249,7 +339,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanUnlockLockedQueue(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanUnlockLockedQueue(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->unlock();
|
$uglyQueue->unlock();
|
||||||
|
|
||||||
$this->assertFileNotExists($uglyQueue->getLockFile());
|
$this->assertFileNotExists($uglyQueue->getLockFile());
|
||||||
@@ -265,7 +355,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsLockedReturnsFalseAfterUnlockingQueue(\DCarbone\UglyQueue $uglyQueue)
|
public function testIsLockedReturnsFalseAfterUnlockingQueue(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$isLocked = $uglyQueue->isLocked();
|
$isLocked = $uglyQueue->isLocked();
|
||||||
|
|
||||||
$this->assertFalse($isLocked);
|
$this->assertFalse($isLocked);
|
||||||
@@ -281,7 +371,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsLockedReturnsFalseWithStaleQueueLockFile(\DCarbone\UglyQueue $uglyQueue)
|
public function testIsLockedReturnsFalseWithStaleQueueLockFile(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->lock(2);
|
$uglyQueue->lock(2);
|
||||||
$isLocked = $uglyQueue->isLocked();
|
$isLocked = $uglyQueue->isLocked();
|
||||||
$this->assertTrue($isLocked);
|
$this->assertTrue($isLocked);
|
||||||
@@ -302,7 +392,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanLockQueueWithValidIntegerValue(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanLockQueueWithValidIntegerValue(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$locked = $uglyQueue->lock(200);
|
$locked = $uglyQueue->lock(200);
|
||||||
|
|
||||||
$this->assertTrue($locked);
|
$this->assertTrue($locked);
|
||||||
@@ -329,7 +419,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanPopulateQueueTempFileAfterInitializationAndAcquiringLock(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanPopulateQueueTempFileAfterInitializationAndAcquiringLock(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
foreach(array_reverse($this->tastySandwich, true) as $k=>$v)
|
foreach(array_reverse($this->tastySandwich, true) as $k=>$v)
|
||||||
{
|
{
|
||||||
$added = $uglyQueue->addItem($k, $v);
|
$added = $uglyQueue->addItem($k, $v);
|
||||||
@@ -356,7 +446,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanForciblyUpdateQueueFileFromTempFile(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanForciblyUpdateQueueFileFromTempFile(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->_populateQueue();
|
$uglyQueue->_populateQueue();
|
||||||
|
|
||||||
$this->assertFileNotExists($uglyQueue->getQueueTmpFile());
|
$this->assertFileNotExists($uglyQueue->getQueueTmpFile());
|
||||||
@@ -367,7 +457,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \DCarbone\UglyQueue::getQueueItemCount
|
* @covers \DCarbone\UglyQueue::count
|
||||||
* @uses \DCarbone\UglyQueue
|
* @uses \DCarbone\UglyQueue
|
||||||
* @uses \DCarbone\Helpers\FileHelper
|
* @uses \DCarbone\Helpers\FileHelper
|
||||||
* @depends testCanPopulateQueueTempFileAfterInitializationAndAcquiringLock
|
* @depends testCanPopulateQueueTempFileAfterInitializationAndAcquiringLock
|
||||||
@@ -388,7 +478,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testKeyExistsReturnsTrueWithPopulatedQueue(\DCarbone\UglyQueue $uglyQueue)
|
public function testKeyExistsReturnsTrueWithPopulatedQueue(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$exists = $uglyQueue->keyExistsInQueue(5);
|
$exists = $uglyQueue->keyExistsInQueue(5);
|
||||||
|
|
||||||
$this->assertTrue($exists);
|
$this->assertTrue($exists);
|
||||||
@@ -403,7 +493,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExceptionThrownWhenTryingToProcessLockedQueueWithNonInteger(\DCarbone\UglyQueue $uglyQueue)
|
public function testExceptionThrownWhenTryingToProcessLockedQueueWithNonInteger(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->retrieveItems('Eleventy Billion');
|
$uglyQueue->retrieveItems('Eleventy Billion');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,13 +506,13 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExceptionThrownWhenTryingToProcessLockedQueueWithIntegerLessThan1(\DCarbone\UglyQueue $uglyQueue)
|
public function testExceptionThrownWhenTryingToProcessLockedQueueWithIntegerLessThan1(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$uglyQueue->retrieveItems(0);
|
$uglyQueue->retrieveItems(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \DCarbone\UglyQueue::retrieveItems
|
* @covers \DCarbone\UglyQueue::retrieveItems
|
||||||
* @covers \DCarbone\UglyQueue::getQueueItemCount
|
* @covers \DCarbone\UglyQueue::count
|
||||||
* @uses \DCarbone\UglyQueue
|
* @uses \DCarbone\UglyQueue
|
||||||
* @uses \DCarbone\Helpers\FileHelper
|
* @uses \DCarbone\Helpers\FileHelper
|
||||||
* @depends testCanPopulateQueueTempFileAfterInitializationAndAcquiringLock
|
* @depends testCanPopulateQueueTempFileAfterInitializationAndAcquiringLock
|
||||||
@@ -431,7 +521,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCanGetPartialQueueContents(\DCarbone\UglyQueue $uglyQueue)
|
public function testCanGetPartialQueueContents(\DCarbone\UglyQueue $uglyQueue)
|
||||||
{
|
{
|
||||||
echo __FUNCTION__."\n";
|
|
||||||
$process = $uglyQueue->retrieveItems(5);
|
$process = $uglyQueue->retrieveItems(5);
|
||||||
|
|
||||||
$this->assertEquals(5, count($process));
|
$this->assertEquals(5, count($process));
|
||||||
@@ -446,7 +536,7 @@ class UglyQueueTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \DCarbone\UglyQueue::retrieveItems
|
* @covers \DCarbone\UglyQueue::retrieveItems
|
||||||
* @covers \DCarbone\UglyQueue::getQueueItemCount
|
* @covers \DCarbone\UglyQueue::count
|
||||||
* @uses \DCarbone\UglyQueue
|
* @uses \DCarbone\UglyQueue
|
||||||
* @uses \DCarbone\Helpers\FileHelper
|
* @uses \DCarbone\Helpers\FileHelper
|
||||||
* @depends testCanGetPartialQueueContents
|
* @depends testCanGetPartialQueueContents
|
||||||
|
|||||||
Reference in New Issue
Block a user