MediaWiki  1.30.0
JobQueueMemoryTest.php
Go to the documentation of this file.
1 <?php
2 
11 class 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 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:268
JobQueueMemoryTest\newJobQueue
newJobQueue()
Definition: JobQueueMemoryTest.php:16
JobQueueMemoryTest\testJobFromSpecInternal
testJobFromSpecInternal()
Definition: JobQueueMemoryTest.php:52
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
JobQueueMemoryTest
JobQueueMemory.
Definition: JobQueueMemoryTest.php:11
JobQueueMemoryTest\newJobSpecification
newJobSpecification()
Definition: JobQueueMemoryTest.php:24
JobQueueMemoryTest\testGetAllQueuedJobs
testGetAllQueuedJobs()
Definition: JobQueueMemoryTest.php:33
$queue
$queue
Definition: mergeMessageFileList.php:161
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:2807
JobQueue\factory
static factory(array $params)
Get a job queue object of the specified type.
Definition: JobQueue.php:108
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:47
JobSpecification
Job queue task description base code.
Definition: JobSpecification.php:104
JobQueueMemoryTest\testGetAllAcquiredJobs
testGetAllAcquiredJobs()
Definition: JobQueueMemoryTest.php:41