4 * @covers JobQueueMemory
9 * @author Thiemo Mättig
11 class JobQueueMemoryTest
extends PHPUnit_Framework_TestCase
{
14 * @return JobQueueMemory
16 private function newJobQueue() {
17 return JobQueue
::factory( array(
18 'class' => 'JobQueueMemory',
24 private function newJobSpecification() {
25 return new JobSpecification(
27 array( 'customParameter' => null ),
29 Title
::newFromText( 'Custom title' )
33 public function testGetAllQueuedJobs() {
34 $queue = $this->newJobQueue();
35 $this->assertCount( 0, $queue->getAllQueuedJobs() );
37 $queue->push( $this->newJobSpecification() );
38 $this->assertCount( 1, $queue->getAllQueuedJobs() );
41 public function testGetAllAcquiredJobs() {
42 $queue = $this->newJobQueue();
43 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
45 $queue->push( $this->newJobSpecification() );
46 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
49 $this->assertCount( 1, $queue->getAllAcquiredJobs() );
52 public function testJobFromSpecInternal() {
53 $queue = $this->newJobQueue();
54 $job = $queue->jobFromSpecInternal( $this->newJobSpecification() );
55 $this->assertInstanceOf( 'Job', $job );
56 $this->assertSame( 'null', $job->getType() );
57 $this->assertArrayHasKey( 'customParameter', $job->getParams() );
58 $this->assertSame( 'Custom title', $job->getTitle()->getText() );