6 class JobTest
extends MediaWikiTestCase
{
9 * @dataProvider provideTestToString
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();
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
65 "rootJobSignature" => "45868e99bba89064e4483743ebb9b682ef95c1a7",
66 "rootJobTimestamp" => "20160309110158",
68 "file" => "db1023-bin.001288",
70 "asOfTime" => 1457521464.3814
72 "triggeredRecursive" => true
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 ' .
84 public function getMockJob( $params ) {
85 $mock = $this->getMockForAbstractClass(
87 [ 'someCommand', new Title(), $params ],