Merge "Make unused variable optional in ChangesList::insertDiffHist"
[lhc/web/wiklou.git] / tests / phpunit / includes / jobqueue / JobTest.php
1 <?php
2
3 /**
4 * @author Addshore
5 */
6 class JobTest extends MediaWikiTestCase {
7
8 /**
9 * @dataProvider provideTestToString
10 *
11 * @param Job $job
12 * @param string $expected
13 *
14 * @covers Job::toString
15 */
16 public function testToString( $job, $expected ) {
17 $this->assertEquals( $expected, $job->toString() );
18 }
19
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}' ) );
25
26 return [
27 [
28 $this->getMockJob( false ),
29 'someCommand '
30 ],
31 [
32 $this->getMockJob( [ 'key' => 'val' ] ),
33 'someCommand key=val'
34 ],
35 [
36 $this->getMockJob( [ 'key' => [ 'inkey' => 'inval' ] ] ),
37 'someCommand key={"inkey":"inval"}'
38 ],
39 [
40 $this->getMockJob( [ 'val1' ] ),
41 'someCommand 0=val1'
42 ],
43 [
44 $this->getMockJob( [ 'val1', 'val2' ] ),
45 'someCommand 0=val1 1=val2'
46 ],
47 [
48 $this->getMockJob( [ new stdClass() ] ),
49 'someCommand 0=object(stdClass)'
50 ],
51 [
52 $this->getMockJob( [ $mockToStringObj ] ),
53 'someCommand 0={STRING_OBJ_VAL}'
54 ],
55 ];
56 }
57
58 public function getMockJob( $params ) {
59 $mock = $this->getMockForAbstractClass(
60 'Job',
61 [ 'someCommand', new Title(), $params ],
62 'SomeJob'
63 );
64 return $mock;
65 }
66
67 }