MediaWiki REL1_31
JobQueueMemoryTest.php
Go to the documentation of this file.
1<?php
2
11class JobQueueMemoryTest extends PHPUnit\Framework\TestCase {
12
13 use MediaWikiCoversValidator;
14
18 private function newJobQueue() {
19 return JobQueue::factory( [
20 'class' => JobQueueMemory::class,
21 'wiki' => wfWikiID(),
22 'type' => 'null',
23 ] );
24 }
25
26 private function newJobSpecification() {
27 return new JobSpecification(
28 'null',
29 [ 'customParameter' => null ],
30 [],
31 Title::newFromText( 'Custom title' )
32 );
33 }
34
35 public function testGetAllQueuedJobs() {
36 $queue = $this->newJobQueue();
37 $this->assertCount( 0, $queue->getAllQueuedJobs() );
38
39 $queue->push( $this->newJobSpecification() );
40 $this->assertCount( 1, $queue->getAllQueuedJobs() );
41 }
42
43 public function testGetAllAcquiredJobs() {
44 $queue = $this->newJobQueue();
45 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
46
47 $queue->push( $this->newJobSpecification() );
48 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
49
50 $queue->pop();
51 $this->assertCount( 1, $queue->getAllAcquiredJobs() );
52 }
53
54 public function testJobFromSpecInternal() {
55 $queue = $this->newJobQueue();
56 $job = $queue->jobFromSpecInternal( $this->newJobSpecification() );
57 $this->assertInstanceOf( Job::class, $job );
58 $this->assertSame( 'null', $job->getType() );
59 $this->assertArrayHasKey( 'customParameter', $job->getParams() );
60 $this->assertSame( 'Custom title', $job->getTitle()->getText() );
61 }
62
63}
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