Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / jobqueue / JobTest.php
blob93069d2e8df8edc1f9b84df5c0f3596221c7851a
1 <?php
3 /**
4 * @author Adam Shorland
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', array( '__toString' ) );
22 $mockToStringObj->expects( $this->any() )
23 ->method( '__toString' )
24 ->will( $this->returnValue( '{STRING_OBJ_VAL}' ) );
26 return array(
27 array(
28 $this->getMockJob( false ),
29 'someCommand '
31 array(
32 $this->getMockJob( array( 'key' => 'val' ) ),
33 'someCommand key=val'
35 array(
36 $this->getMockJob( array( 'key' => array( 'inkey' => 'inval' ) ) ),
37 'someCommand key={"inkey":"inval"}'
39 array(
40 $this->getMockJob( array( 'val1' ) ),
41 'someCommand 0=val1'
43 array(
44 $this->getMockJob( array( 'val1', 'val2' ) ),
45 'someCommand 0=val1 1=val2'
47 array(
48 $this->getMockJob( array( new stdClass() ) ),
49 'someCommand 0=object(stdClass)'
51 array(
52 $this->getMockJob( array( $mockToStringObj ) ),
53 'someCommand 0={STRING_OBJ_VAL}'
58 public function getMockJob( $params ) {
59 $mock = $this->getMockForAbstractClass(
60 'Job',
61 array( 'someCommand', new Title(), $params ),
62 'SomeJob'
64 return $mock;