Merge "mediawiki.api.parse: Use formatversion=2 for API requests"
[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', array( '__toString' ) );
22 $mockToStringObj->expects( $this->any() )
23 ->method( '__toString' )
24 ->will( $this->returnValue( '{STRING_OBJ_VAL}' ) );
25
26 return array(
27 array(
28 $this->getMockJob( false ),
29 'someCommand '
30 ),
31 array(
32 $this->getMockJob( array( 'key' => 'val' ) ),
33 'someCommand key=val'
34 ),
35 array(
36 $this->getMockJob( array( 'key' => array( 'inkey' => 'inval' ) ) ),
37 'someCommand key={"inkey":"inval"}'
38 ),
39 array(
40 $this->getMockJob( array( 'val1' ) ),
41 'someCommand 0=val1'
42 ),
43 array(
44 $this->getMockJob( array( 'val1', 'val2' ) ),
45 'someCommand 0=val1 1=val2'
46 ),
47 array(
48 $this->getMockJob( array( new stdClass() ) ),
49 'someCommand 0=object(stdClass)'
50 ),
51 array(
52 $this->getMockJob( array( $mockToStringObj ) ),
53 'someCommand 0={STRING_OBJ_VAL}'
54 ),
55 );
56 }
57
58 public function getMockJob( $params ) {
59 $mock = $this->getMockForAbstractClass(
60 'Job',
61 array( 'someCommand', new Title(), $params ),
62 'SomeJob'
63 );
64 return $mock;
65 }
66
67 }