MediaWiki REL1_30
JobQueueMemoryTest.php
Go to the documentation of this file.
1<?php
2
11class JobQueueMemoryTest extends PHPUnit_Framework_TestCase {
12
16 private function newJobQueue() {
17 return JobQueue::factory( [
18 'class' => 'JobQueueMemory',
19 'wiki' => wfWikiID(),
20 'type' => 'null',
21 ] );
22 }
23
24 private function newJobSpecification() {
25 return new JobSpecification(
26 'null',
27 [ 'customParameter' => null ],
28 [],
29 Title::newFromText( 'Custom title' )
30 );
31 }
32
33 public function testGetAllQueuedJobs() {
34 $queue = $this->newJobQueue();
35 $this->assertCount( 0, $queue->getAllQueuedJobs() );
36
37 $queue->push( $this->newJobSpecification() );
38 $this->assertCount( 1, $queue->getAllQueuedJobs() );
39 }
40
41 public function testGetAllAcquiredJobs() {
42 $queue = $this->newJobQueue();
43 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
44
45 $queue->push( $this->newJobSpecification() );
46 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
47
48 $queue->pop();
49 $this->assertCount( 1, $queue->getAllAcquiredJobs() );
50 }
51
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() );
59 }
60
61}
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
static factory(array $params)
Get a job queue object of the specified type.
Definition JobQueue.php:108
Job queue task description base code.
if(count( $args)< 1) $job