Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / includes / jobqueue / JobTest.php
blob600a36ffe48eff94f41f35d3fa03065ca1135117
1 <?php
3 /**
4 * @author Addshore
5 */
6 class JobTest extends MediaWikiTestCase {
8 /**
9 * @dataProvider provideTestToString
11 * @param Job $job
12 * @param string $expected
14 * @covers Job::toString
16 public function testToString( $job, $expected ) {
17 $this->assertEquals( $expected, $job->toString() );
20 public function provideTestToString() {
21 $mockToStringObj = $this->getMock( 'stdClass', [ '__toString' ] );
22 $mockToStringObj->expects( $this->any() )
23 ->method( '__toString' )
24 ->will( $this->returnValue( '{STRING_OBJ_VAL}' ) );
26 $requestId = 'requestId=' . WebRequest::getRequestId();
28 return [
30 $this->getMockJob( false ),
31 'someCommand ' . $requestId
34 $this->getMockJob( [ 'key' => 'val' ] ),
35 'someCommand key=val ' . $requestId
38 $this->getMockJob( [ 'key' => [ 'inkey' => 'inval' ] ] ),
39 'someCommand key={"inkey":"inval"} ' . $requestId
42 $this->getMockJob( [ 'val1' ] ),
43 'someCommand 0=val1 ' . $requestId
46 $this->getMockJob( [ 'val1', 'val2' ] ),
47 'someCommand 0=val1 1=val2 ' . $requestId
50 $this->getMockJob( [ new stdClass() ] ),
51 'someCommand 0=object(stdClass) ' . $requestId
54 $this->getMockJob( [ $mockToStringObj ] ),
55 'someCommand 0={STRING_OBJ_VAL} ' . $requestId
58 $this->getMockJob( [
59 "pages" => [
60 "932737" => [
62 "Robert_James_Waller"
65 "rootJobSignature" => "45868e99bba89064e4483743ebb9b682ef95c1a7",
66 "rootJobTimestamp" => "20160309110158",
67 "masterPos" => [
68 "file" => "db1023-bin.001288",
69 "pos" => "308257743",
70 "asOfTime" => 1457521464.3814
72 "triggeredRecursive" => true
73 ] ),
74 'someCommand pages={"932737":[0,"Robert_James_Waller"]} ' .
75 'rootJobSignature=45868e99bba89064e4483743ebb9b682ef95c1a7 ' .
76 'rootJobTimestamp=20160309110158 masterPos=' .
77 '{"file":"db1023-bin.001288","pos":"308257743","asOfTime":1457521464.3814} ' .
78 'triggeredRecursive=1 ' .
79 $requestId
84 public function getMockJob( $params ) {
85 $mock = $this->getMockForAbstractClass(
86 'Job',
87 [ 'someCommand', new Title(), $params ],
88 'SomeJob'
90 return $mock;