1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
/**
* @author Adam Shorland
*/
class JobTest extends MediaWikiTestCase {
/**
* @dataProvider provideTestToString
*
* @param Job $job
* @param string $expected
*
* @covers Job::toString
*/
public function testToString( $job, $expected ) {
$this->assertEquals( $expected, $job->toString() );
}
public function provideTestToString() {
$mockToStringObj = $this->getMock( 'stdClass', array( '__toString' ) );
$mockToStringObj->expects( $this->any() )
->method( '__toString' )
->will( $this->returnValue( '{STRING_OBJ_VAL}' ) );
return array(
array(
$this->getMockJob( false ),
'someCommand '
),
array(
$this->getMockJob( array( 'key' => 'val' ) ),
'someCommand key=val'
),
array(
$this->getMockJob( array( 'key' => array( 'inkey' => 'inval' ) ) ),
'someCommand key={"inkey":"inval"}'
),
array(
$this->getMockJob( array( 'val1' ) ),
'someCommand 0=val1'
),
array(
$this->getMockJob( array( 'val1', 'val2' ) ),
'someCommand 0=val1 1=val2'
),
array(
$this->getMockJob( array( new stdClass() ) ),
'someCommand 0=object(stdClass)'
),
array(
$this->getMockJob( array( $mockToStringObj ) ),
'someCommand 0={STRING_OBJ_VAL}'
),
);
}
public function getMockJob( $params ) {
$mock = $this->getMockForAbstractClass(
'Job',
array( 'someCommand', new Title(), $params ),
'SomeJob'
);
return $mock;
}
}
|