4 * @covers JobQueueMemory
8 * @license GPL-2.0-or-later
11 class JobQueueMemoryTest
extends PHPUnit\Framework\TestCase
{
13 use MediaWikiCoversValidator
;
16 * @return JobQueueMemory
18 private function newJobQueue() {
19 return JobQueue
::factory( [
20 'class' => JobQueueMemory
::class,
21 'domain' => WikiMap
::getCurrentWikiDbDomain()->getId(),
26 private function newJobSpecification() {
27 return new JobSpecification(
29 [ 'customParameter' => null ],
31 Title
::newFromText( 'Custom title' )
35 public function testGetAllQueuedJobs() {
36 $queue = $this->newJobQueue();
37 $this->assertCount( 0, $queue->getAllQueuedJobs() );
39 $queue->push( $this->newJobSpecification() );
40 $this->assertCount( 1, $queue->getAllQueuedJobs() );
43 public function testGetAllAcquiredJobs() {
44 $queue = $this->newJobQueue();
45 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
47 $queue->push( $this->newJobSpecification() );
48 $this->assertCount( 0, $queue->getAllAcquiredJobs() );
51 $this->assertCount( 1, $queue->getAllAcquiredJobs() );
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() );