blob: 64d34a541213bfddf641516d94abfb9058176ba9 (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<?php
namespace SMW\Tests\Query;
use SMW\Query\QueryLinker;
/**
* @covers SMW\Query\QueryLinker
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 2.4
*
* @author mwjames
*/
class QueryLinkerTest extends \PHPUnit_Framework_TestCase {
public function testCanConstruct() {
$this->assertInstanceOf(
'SMW\Query\QueryLinker',
new QueryLinker()
);
}
public function testGet() {
$query = $this->getMockBuilder( '\SMWQuery' )
->disableOriginalConstructor()
->getMock();
$query->expects( $this->once() )
->method( 'getExtraPrintouts' )
->will( $this->returnValue( [] ) );
$query->expects( $this->once() )
->method( 'getSortKeys' )
->will( $this->returnValue( [] ) );
$parameters = [
'Foo' => 'Bar',
'Foobar'
];
$this->assertInstanceOf(
'SMWInfolink',
QueryLinker::get( $query, $parameters )
);
}
/**
* @dataProvider sortOrderProvider
*/
public function testSort_PredefinedProperty( $sortKeys, $expected ) {
$query = $this->getMockBuilder( '\SMWQuery' )
->disableOriginalConstructor()
->getMock();
$query->expects( $this->once() )
->method( 'getExtraPrintouts' )
->will( $this->returnValue( [] ) );
$query->expects( $this->once() )
->method( 'getSortKeys' )
->will( $this->returnValue( $sortKeys ) );
$link = QueryLinker::get( $query );
$link->setCompactLink( false );
$this->assertContains(
$expected,
$link->getLocalURL()
);
}
public function sortOrderProvider() {
yield[
[ '_MDAT' => 'DESC' ],
'&order=desc&sort=Modification%20date'
];
yield[
[ '' => 'ASC' ],
'&mainlabel=&source=&offset='
];
yield[
[ 'Foo_bar' => 'ASC' ],
'&mainlabel=&source=&offset=&order=asc&sort=Foo%20bar'
];
yield[
[ '' => 'ASC', 'Foo_bar' => 'DESC' ],
'&mainlabel=&source=&offset=&order=asc%2Cdesc&sort=%2CFoo%20bar'
];
}
}
|