|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SRF\Tests\Outline; |
|
4
|
|
|
|
|
5
|
|
|
use SRF\Outline\OutlineResultPrinter; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @covers \SRF\Outline\OutlineResultPrinter |
|
9
|
|
|
* @group semantic-result-formats |
|
10
|
|
|
* |
|
11
|
|
|
* @license GNU GPL v2+ |
|
12
|
|
|
* @since 3.1 |
|
13
|
|
|
* |
|
14
|
|
|
* @author mwjames |
|
15
|
|
|
*/ |
|
16
|
|
|
class OutlineResultPrinterTest extends \PHPUnit_Framework_TestCase { |
|
17
|
|
|
|
|
18
|
|
|
private $queryResult; |
|
19
|
|
|
|
|
20
|
|
|
protected function setUp() { |
|
21
|
|
|
parent::setUp(); |
|
22
|
|
|
|
|
23
|
|
|
$this->queryResult = $this->getMockBuilder( '\SMWQueryResult' ) |
|
24
|
|
|
->disableOriginalConstructor() |
|
25
|
|
|
->getMock(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testCanConstruct() { |
|
29
|
|
|
|
|
30
|
|
|
$this->assertInstanceOf( |
|
31
|
|
|
OutlineResultPrinter::class, |
|
32
|
|
|
new OutlineResultPrinter( 'outline' ) |
|
33
|
|
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testGetResult_LinkOnNonFileOutput() { |
|
37
|
|
|
|
|
38
|
|
|
$link = $this->getMockBuilder( '\SMWInfolink' ) |
|
39
|
|
|
->disableOriginalConstructor() |
|
40
|
|
|
->getMock(); |
|
41
|
|
|
|
|
42
|
|
|
$link->expects( $this->any() ) |
|
43
|
|
|
->method( 'getText' ) |
|
44
|
|
|
->will( $this->returnValue( 'foo_link' ) ); |
|
45
|
|
|
|
|
46
|
|
|
$this->queryResult->expects( $this->any() ) |
|
47
|
|
|
->method( 'getErrors' ) |
|
48
|
|
|
->will( $this->returnValue( [] ) ); |
|
49
|
|
|
|
|
50
|
|
|
$this->queryResult->expects( $this->any() ) |
|
51
|
|
|
->method( 'getCount' ) |
|
52
|
|
|
->will( $this->returnValue( 1 ) ); |
|
53
|
|
|
|
|
54
|
|
|
$instance = new OutlineResultPrinter( |
|
55
|
|
|
'outline' |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
// IParam is an empty interface !!! so we use stdClass |
|
59
|
|
|
$outlineproperties = $this->getMockBuilder( '\stdClass' ) |
|
60
|
|
|
->disableOriginalConstructor() |
|
61
|
|
|
->setMethods( [ 'getName', 'getValue' ] ) |
|
62
|
|
|
->getMock(); |
|
63
|
|
|
|
|
64
|
|
|
$outlineproperties->expects( $this->any() ) |
|
65
|
|
|
->method( 'getName' ) |
|
66
|
|
|
->will( $this->returnValue( 'outlineproperties' ) ); |
|
67
|
|
|
|
|
68
|
|
|
$outlineproperties->expects( $this->any() ) |
|
69
|
|
|
->method( 'getValue' ) |
|
70
|
|
|
->will( $this->returnValue( [] ) ); |
|
71
|
|
|
|
|
72
|
|
|
$template = $this->getMockBuilder( '\stdClass' ) |
|
73
|
|
|
->disableOriginalConstructor() |
|
74
|
|
|
->setMethods( [ 'getName', 'getValue' ] ) |
|
75
|
|
|
->getMock(); |
|
76
|
|
|
|
|
77
|
|
|
$template->expects( $this->any() ) |
|
78
|
|
|
->method( 'getName' ) |
|
79
|
|
|
->will( $this->returnValue( 'template' ) ); |
|
80
|
|
|
|
|
81
|
|
|
$template->expects( $this->any() ) |
|
82
|
|
|
->method( 'getValue' ) |
|
83
|
|
|
->will( $this->returnValue( '' ) ); |
|
84
|
|
|
|
|
85
|
|
|
$parameters = [ |
|
86
|
|
|
$outlineproperties, |
|
87
|
|
|
$template |
|
88
|
|
|
]; |
|
89
|
|
|
|
|
90
|
|
|
$this->assertContains( |
|
91
|
|
|
"<ul>\n</ul>\n", |
|
92
|
|
|
$instance->getResult( $this->queryResult, $parameters, SMW_OUTPUT_HTML ) |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|