Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5974324
JobFactoryTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
JobFactoryTest.php
View Options
<?php
use
MediaWiki\JobQueue\JobFactory
;
use
MediaWiki\Title\Title
;
/**
* @author Addshore
* @covers \MediaWiki\JobQueue\JobFactory
*/
class
JobFactoryTest
extends
MediaWikiIntegrationTestCase
{
/**
* @dataProvider provideTestNewJob
*/
public
function
testNewJob
(
$handler
,
$expectedClass
)
{
$specs
=
[
'testdummy'
=>
$handler
];
$factory
=
new
JobFactory
(
$this
->
getServiceContainer
()->
getObjectFactory
(),
$specs
);
$job
=
$factory
->
newJob
(
'testdummy'
,
Title
::
newMainPage
(),
[]
);
$this
->
assertInstanceOf
(
$expectedClass
,
$job
);
$job2
=
$factory
->
newJob
(
'testdummy'
,
[]
);
$this
->
assertInstanceOf
(
$expectedClass
,
$job2
);
$this
->
assertNotSame
(
$job
,
$job2
,
'should not reuse instance'
);
$job3
=
$factory
->
newJob
(
'testdummy'
,
[
'namespace'
=>
NS_MAIN
,
'title'
=>
'JobTestTitle'
]
);
$this
->
assertInstanceOf
(
$expectedClass
,
$job3
);
$this
->
assertNotSame
(
$job
,
$job3
,
'should not reuse instance'
);
}
public
function
provideTestNewJob
()
{
return
[
'class name, no title'
=>
[
'NullJob'
,
NullJob
::
class
],
'class name with title'
=>
[
DeleteLinksJob
::
class
,
DeleteLinksJob
::
class
],
'closure'
=>
[
static
function
(
Title
$title
,
array
$params
)
{
return
new
NullJob
(
$params
);
},
NullJob
::
class
],
'function'
=>
[
[
$this
,
'newNullJob'
],
NullJob
::
class
],
'object spec, no title'
=>
[
[
'class'
=>
'NullJob'
],
NullJob
::
class
],
'object spec with title'
=>
[
[
'class'
=>
DeleteLinksJob
::
class
],
DeleteLinksJob
::
class
],
'object spec with no title and not subclass of GenericParameterJob'
=>
[
[
'class'
=>
ParsoidCachePrewarmJob
::
class
,
'services'
=>
[
'ParserOutputAccess'
,
'PageStore'
,
'RevisionLookup'
,
'ParsoidSiteConfig'
,
],
'needsPage'
=>
false
],
ParsoidCachePrewarmJob
::
class
]
];
}
public
function
newNullJob
(
Title
$title
,
array
$params
)
{
return
new
NullJob
(
$params
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 17:18 (1 d, 9 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
61/f7/f2b586265470e58e652a0a46807d
Default Alt Text
JobFactoryTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment