MediaWiki
REL1_31
JobQueueMemoryTest.php
Go to the documentation of this file.
1
<?php
2
11
class
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
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition
GlobalFunctions.php:2763
JobQueueMemoryTest
JobQueueMemory.
Definition
JobQueueMemoryTest.php:11
JobQueueMemoryTest\testJobFromSpecInternal
testJobFromSpecInternal()
Definition
JobQueueMemoryTest.php:54
JobQueueMemoryTest\testGetAllAcquiredJobs
testGetAllAcquiredJobs()
Definition
JobQueueMemoryTest.php:43
JobQueueMemoryTest\testGetAllQueuedJobs
testGetAllQueuedJobs()
Definition
JobQueueMemoryTest.php:35
JobQueueMemoryTest\newJobSpecification
newJobSpecification()
Definition
JobQueueMemoryTest.php:26
JobQueueMemoryTest\newJobQueue
newJobQueue()
Definition
JobQueueMemoryTest.php:18
JobQueue\factory
static factory(array $params)
Get a job queue object of the specified type.
Definition
JobQueue.php:108
JobSpecification
Job queue task description base code.
Definition
JobSpecification.php:103
$queue
$queue
Definition
mergeMessageFileList.php:160
$job
if(count( $args)< 1) $job
Definition
recompressTracked.php:47
tests
phpunit
includes
jobqueue
JobQueueMemoryTest.php
Generated on Mon Nov 25 2024 15:36:24 for MediaWiki by
1.10.0