Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / includes / jobqueue / JobQueueMemoryTest.php
blob4b03fda7b7d71e12a7419833d2cd0694b7187eed
1 <?php
3 /**
4 * @covers JobQueueMemory
6 * @group JobQueue
8 * @licence GNU GPL v2+
9 * @author Thiemo Mättig
11 class JobQueueMemoryTest extends PHPUnit_Framework_TestCase {
13 /**
14 * @return JobQueueMemory
16 private function newJobQueue() {
17 return JobQueue::factory( [
18 'class' => 'JobQueueMemory',
19 'wiki' => wfWikiID(),
20 'type' => 'null',
21 ] );
24 private function newJobSpecification() {
25 return new JobSpecification(
26 'null',
27 [ 'customParameter' => null ],
28 [],
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() );
48 $queue->pop();
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() );