1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:
<?php
namespace GuzzleHttp\Promise\Test;
use GuzzleHttp\Promise\TaskQueue;
class TaskQueueTest extends \PHPUnit_Framework_TestCase
{
public function testKnowsIfEmpty()
{
$tq = new TaskQueue(false);
$this->assertTrue($tq->isEmpty());
}
public function testKnowsIfFull()
{
$tq = new TaskQueue(false);
$tq->add(function () {});
$this->assertFalse($tq->isEmpty());
}
public function testExecutesTasksInOrder()
{
$tq = new TaskQueue(false);
$called = [];
$tq->add(function () use (&$called) { $called[] = 'a'; });
$tq->add(function () use (&$called) { $called[] = 'b'; });
$tq->add(function () use (&$called) { $called[] = 'c'; });
$tq->run();
$this->assertEquals(['a', 'b', 'c'], $called);
}
}