1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Scribunto\Tests; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @covers \SMW\Scribunto\ScribuntoLuaLibrary |
7
|
|
|
* @group semantic-scribunto |
8
|
|
|
* |
9
|
|
|
* @license GNU GPL v2+ |
10
|
|
|
* @since 1.0 |
11
|
|
|
* |
12
|
|
|
* @author mwjames |
13
|
|
|
*/ |
14
|
|
|
class ScribuntoLuaLibraryResultsTest extends ScribuntoLuaEngineTestBase { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Lua test module |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected static $moduleName = 'SMW\Scribunto\Tests\ScribuntoLuaLibraryResultsTest'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* ScribuntoLuaEngineTestBase::getTestModules |
24
|
|
|
*/ |
25
|
|
|
public function getTestModules() { |
26
|
|
|
return parent::getTestModules() + [ |
27
|
|
|
'SMW\Scribunto\Tests\ScribuntoLuaLibraryResultsTest' => __DIR__ . '/' . 'mw.smw.results.tests.lua', |
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Tests method getQueryResult |
33
|
|
|
* |
34
|
|
|
* @return void |
35
|
|
|
*/ |
36
|
|
|
public function testGetQueryResult() { |
37
|
|
|
$this->assertArrayHasKey( |
38
|
|
|
'meta', |
39
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult()[0] |
40
|
|
|
); |
41
|
|
|
$this->assertArrayHasKey( |
42
|
|
|
'count', |
43
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult()[0]['meta'] |
44
|
|
|
); |
45
|
|
|
$this->assertEquals( |
46
|
|
|
0, |
47
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult()[0]['meta']['count'] |
48
|
|
|
); |
49
|
|
|
$this->assertArrayHasKey( |
50
|
|
|
'printrequests', |
51
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult( '[[Modification date::+]]|?Modification date|limit=0|mainlabel=-' )[0] |
52
|
|
|
); |
53
|
|
|
$this->assertArrayHasKey( |
54
|
|
|
1, |
55
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult( '[[Modification date::+]]|?Modification date|limit=0|mainlabel=-' )[0]['printrequests'] |
56
|
|
|
); |
57
|
|
|
$this->assertArrayHasKey( |
58
|
|
|
'label', |
59
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult( '[[Modification date::+]]|?Modification date|limit=0|mainlabel=-' )[0]['printrequests'][1] |
60
|
|
|
); |
61
|
|
|
$this->assertEquals( |
62
|
|
|
'Modification date', |
63
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult( '[[Modification date::+]]|?Modification date|limit=0|mainlabel=-' )[0]['printrequests'][1]['label'] |
64
|
|
|
); |
65
|
|
|
$this->assertEquals( |
66
|
|
|
'Modification date', |
67
|
|
|
$this->getScribuntoLuaLibrary()->getQueryResult( [ '[[Modification date::+]]', '?Modification date', 'limit' => 0, 'mainlabel=-' ] )[0]['printrequests'][1]['label'] |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
} |