blob: 04ab109c66b23f34d19a79157e141cdfd5162b4e (
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
|
<?php
namespace SMW\Tests\MediaWiki\Specials\Ask;
use SMW\MediaWiki\Specials\Ask\SortWidget;
use SMW\Tests\TestEnvironment;
/**
* @covers \SMW\MediaWiki\Specials\Ask\SortWidget
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class SortWidgetTest extends \PHPUnit_Framework_TestCase {
private $stringValidator;
protected function setUp() {
$testEnvironment = new TestEnvironment();
$this->stringValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newStringValidator();
}
public function testDisabled() {
SortWidget::setSortingSupport( false );
$this->assertEmpty(
SortWidget::sortSection( [] )
);
}
public function testEnabledWithEmptyParameters() {
SortWidget::setSortingSupport( true );
$this->assertContains(
'<div id="options-sort" class="smw-ask-options-sort">',
SortWidget::sortSection( [] )
);
}
public function testEnabledWithParameters() {
SortWidget::setSortingSupport( true );
SortWidget::setRandSortingSupport( true );
$result = SortWidget::sortSection(
[
'sort' => 'Foo,bar',
'order' => 'asc,DESC'
]
);
$this->stringValidator->assertThatStringContains(
[
'<div id="sort_div_0" class="smw-ask-sort-input">',
'<input name="sort_num[]" size="35" class="smw-property-input autocomplete-arrow" value="Foo"',
'<select name="order_num[]"><option selected="selected" value="asc">'
],
$result
);
$this->stringValidator->assertThatStringContains(
[
'<div id="sort_div_1" class="smw-ask-sort-input">',
'<input name="sort_num[]" size="35" class="smw-property-input autocomplete-arrow" value="bar"',
'<select name="order_num[]"><option value="asc">.*</option><option selected="selected" value="desc">'
],
$result
);
}
}
|