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 Tobias Oetterer |
13
|
|
|
*/ |
14
|
|
|
class ScribuntoLuaLibrarySubobjectTest extends ScribuntoLuaEngineTestBase { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Lua test module |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected static $moduleName = self::class; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* ScribuntoLuaEngineTestBase::getTestModules |
24
|
|
|
*/ |
25
|
|
|
public function getTestModules() { |
26
|
|
|
return parent::getTestModules() + [ |
27
|
|
|
self::$moduleName => __DIR__ . '/' . 'mw.smw.subobject.tests.lua', |
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Tests method subobject through assertions based upon |
33
|
|
|
* dataProvider {@see dataProviderSubobjectTest} |
34
|
|
|
* |
35
|
|
|
* @dataProvider dataProviderSubobjectTest |
36
|
|
|
* @param array $arguments arguments passed to function |
37
|
|
|
* @param mixed $expected expected return value |
38
|
|
|
*/ |
39
|
|
|
public function testSubobject( $arguments, $expected ) { |
40
|
|
|
$this->assertEquals( |
41
|
|
|
$expected, |
42
|
|
|
call_user_func_array( [ $this->getScribuntoLuaLibrary(), 'subobject' ], $arguments ) |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Data provider for {@see testSubobject} |
48
|
|
|
* |
49
|
|
|
* @see testSubobject |
50
|
|
|
* |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
|
|
public function dataProviderSubobjectTest() |
54
|
|
|
{ |
55
|
|
|
$provider = [ |
56
|
|
|
[ |
57
|
|
|
[ [] ], |
58
|
|
|
[ 1 => true ] |
59
|
|
|
], |
60
|
|
|
[ |
61
|
|
|
[ null ], |
62
|
|
|
[ 1 => true ] |
63
|
|
|
], |
64
|
|
|
[ |
65
|
|
|
[ '' ], |
66
|
|
|
[ 1 => true ] |
67
|
|
|
], |
68
|
|
|
[ |
69
|
|
|
[ [ 'has text=test', 'Is bool=true' ] ], |
70
|
|
|
[ 1 => true ] |
71
|
|
|
], |
72
|
|
|
[ |
73
|
|
|
[ [ 'has type=test', 'Is bool=true' ] ], |
74
|
|
|
[ [ 1 => false, 'error' => wfMessage('smw-datavalue-property-restricted-declarative-use', 'Has type')->inLanguage('en')->plain() ] ] |
75
|
|
|
], |
76
|
|
|
[ |
77
|
|
|
[ [ 'has text=test', 'Is bool=true','1215623e790d918773db943232068a93b21c9f1419cb85666c6558e87f5b7d47=test' ] ], |
78
|
|
|
[ 1 => true ] |
79
|
|
|
], |
80
|
|
|
[ |
81
|
|
|
[ [], '01234567890_testStringAsId' ], |
82
|
|
|
[ 1 => true ] |
83
|
|
|
], |
84
|
|
|
[ |
85
|
|
|
[ null, '01234567890_testStringAsId' ], |
86
|
|
|
[ 1 => true ] |
87
|
|
|
], |
88
|
|
|
[ |
89
|
|
|
[ '', '01234567890_testStringAsId' ], |
90
|
|
|
[ 1 => true ] |
91
|
|
|
], |
92
|
|
|
[ |
93
|
|
|
[ [ 'has text=test', 'Is bool=true' ], '01234567890_testStringAsId' ], |
94
|
|
|
[ 1 => true ] |
95
|
|
|
], |
96
|
|
|
[ |
97
|
|
|
[ [ 'has type=test', 'Allows value=test' ], '01234567890_testStringAsId' ], |
98
|
|
|
[ [ 1 => false, 'error' => '<ul><li>' . wfMessage('smw-datavalue-property-restricted-declarative-use', 'Has type')->inLanguage('en')->plain() . '</li> <!--br--><li>' . wfMessage('smw-datavalue-property-restricted-declarative-use', 'Allows value')->inLanguage('en')->plain() . '</li></ul>' ] ] |
99
|
|
|
], |
100
|
|
|
[ |
101
|
|
|
[ [ 'has text=test', 'Is bool=true' => 'test','1215623e790d918773db943232068a93b21c9f1419cb85666c6558e87f5b7d47=test' ], '01234567890_testStringAsId' ], |
102
|
|
|
[ 1 => true ] |
103
|
|
|
], |
104
|
|
|
]; |
105
|
|
|
|
106
|
|
|
return $provider; |
107
|
|
|
} |
108
|
|
|
} |