@@ -25,21 +25,21 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function execute() { |
27 | 27 | $parser = $this->getParser(); |
28 | - $parser->setTitle( Title::newFromText( 'NO TITLE' ) ); |
|
28 | + $parser->setTitle(Title::newFromText('NO TITLE')); |
|
29 | 29 | $parser->mOptions = new ParserOptions(); |
30 | 30 | $parser->resetOutput(); |
31 | 31 | |
32 | - $apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor( $parser ); |
|
33 | - $apiRequestProcessor->setDebugFlag( $GLOBALS['wgSF_Select_debug'] ); |
|
32 | + $apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor($parser); |
|
33 | + $apiRequestProcessor->setDebugFlag($GLOBALS['wgSF_Select_debug']); |
|
34 | 34 | |
35 | 35 | $resultValues = $apiRequestProcessor->getJsonDecodedResultValuesForRequestParameters( |
36 | 36 | $this->extractRequestParams() |
37 | 37 | ); |
38 | 38 | |
39 | 39 | $result = $this->getResult(); |
40 | - $result->setIndexedTagName( $resultValues->values, 'value' ); |
|
41 | - $result->addValue( $this->getModuleName(), 'values', $resultValues->values ); |
|
42 | - $result->addValue( $this->getModuleName(), 'count', $resultValues->count ); |
|
40 | + $result->setIndexedTagName($resultValues->values, 'value'); |
|
41 | + $result->addValue($this->getModuleName(), 'values', $resultValues->values); |
|
42 | + $result->addValue($this->getModuleName(), 'count', $resultValues->count); |
|
43 | 43 | |
44 | 44 | return true; |
45 | 45 | } |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | * @see ApiBase::getVersion |
88 | 88 | */ |
89 | 89 | public function getVersion() { |
90 | - return __CLASS__ . ': 1.1'; |
|
90 | + return __CLASS__.': 1.1'; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Compatibility helper for MW < 1.32 |
94 | 94 | private function getParser(): Parser { |
95 | - if ( class_exists( \MediaWiki\MediaWikiServices::class ) ) { |
|
95 | + if (class_exists(\MediaWiki\MediaWikiServices::class)) { |
|
96 | 96 | $services = \MediaWiki\MediaWikiServices::getInstance(); |
97 | - if ( is_callable( $services, 'getParserFactory' ) ) { |
|
97 | + if (is_callable($services, 'getParserFactory')) { |
|
98 | 98 | return $services->getParserFactory()->create(); |
99 | 99 | } |
100 | 100 | } |
101 | - return new Parser( $GLOBALS['wgParserConf'] ); |
|
101 | + return new Parser($GLOBALS['wgParserConf']); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | private $SelectField; |
25 | 25 | private $parser; |
26 | 26 | // Defined variables |
27 | - private $other_args_query_parametrized = [ 'query' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ]; |
|
27 | + private $other_args_query_parametrized = ['query' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500']; |
|
28 | 28 | private $expected_result_parametrized_setQuery = "[[Category:Building Complex]][[Part Of Site::@@@@]];?Display Title;format=list;sort=Display Title;sep=,;link=none;headers=hide;limit=500"; |
29 | - private $other_args_query_unparametrized = [ 'query' => '((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ]; |
|
30 | - private $other_args_function_parametrized = [ 'function' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ]; |
|
29 | + private $other_args_query_unparametrized = ['query' => '((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500']; |
|
30 | + private $other_args_function_parametrized = ['function' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500']; |
|
31 | 31 | private $expected_result_parametrized_seFunction = '{{#[[Category:Building Complex]][[Part Of Site::@@@@]];?Display Title;format=list;sort=Display Title;sep=,;link=none;headers=hide;limit=500}}'; |
32 | - private $other_args_function_unparametrized = [ 'function' => 'ask:((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~@@;link~none;headers~hide;limit~500' ]; |
|
32 | + private $other_args_function_unparametrized = ['function' => 'ask:((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~@@;link~none;headers~hide;limit~500']; |
|
33 | 33 | private $expected_result_unparametrized_seFunction = "Building Complex:86543eab-4112-4616-be50-17dcdc24c346 (OFD.AEXH)@@Building Complex:5b9e26f8-6c57-48ff-a6b8-42a4e50fe472 (OFD.AEXH)@@Building Complex:93b076aa-cbe9-4371-8b61-c17c26f1872f (OFD.AMEXH)@@Building Complex:59577450-1582-4d6e-9621-3ac0531a728e (OFD.EEXH)@@Building Complex:1a9bed0b-67de-4e71-8528-f2b6a8907814 (RContiAve.Sport Complex)@@Building Complex:6a2242ea-7536-4a6d-85d2-f2ba4398ef44 (TB.BC)@@Building Complex:2db51fb1-10b6-4d4c-a152-f512914781ff (TB.BD)"; |
34 | 34 | |
35 | 35 | public function testCanConstruct() { |
36 | 36 | |
37 | - $this->assertInstanceOf( '\SFS\SelectField', $this->SelectField ); |
|
37 | + $this->assertInstanceOf('\SFS\SelectField', $this->SelectField); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function testProcessParameters_Query() { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | "", $this->other_args_query_parametrized |
44 | 44 | ); |
45 | 45 | $this->assertTrue( |
46 | - array_key_exists( "query", $this->other_args_query_parametrized ) |
|
46 | + array_key_exists("query", $this->other_args_query_parametrized) |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function testParametrized_setQuery() { |
61 | 61 | |
62 | - $this->SelectField->setQuery( $this->other_args_query_parametrized ); |
|
62 | + $this->SelectField->setQuery($this->other_args_query_parametrized); |
|
63 | 63 | |
64 | 64 | $this->assertEquals( |
65 | 65 | $this->expected_result_parametrized_setQuery, |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | $was_replaced |
79 | 79 | ); |
80 | 80 | |
81 | - $this->assertTrue( count( $was_remove[0] ) == 0 ); |
|
82 | - $this->assertTrue( count( $was_replaced[0] ) > 0 ); |
|
81 | + $this->assertTrue(count($was_remove[0]) == 0); |
|
82 | + $this->assertTrue(count($was_replaced[0]) > 0); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function testUnparametrized_setQuery() { |
86 | 86 | |
87 | - $this->SelectField->setQuery( $this->other_args_query_unparametrized ); |
|
87 | + $this->SelectField->setQuery($this->other_args_query_unparametrized); |
|
88 | 88 | |
89 | - $this->assertTrue( $this->SelectField->getValues() !== null ); |
|
90 | - $this->assertTrue( $this->SelectField->hasStaticValues() ); |
|
89 | + $this->assertTrue($this->SelectField->getValues() !== null); |
|
90 | + $this->assertTrue($this->SelectField->hasStaticValues()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function testParametrized_setFunction() { |
@@ -109,26 +109,26 @@ discard block |
||
109 | 109 | $this->other_args_function_unparametrized |
110 | 110 | ); |
111 | 111 | |
112 | - $this->assertTrue( $this->SelectField->hasStaticValues() ); |
|
112 | + $this->assertTrue($this->SelectField->hasStaticValues()); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | public function testSetSelectIsMultiple_keyExistTrue() { |
116 | - $other_args = [ "part_of_multiple" => "bla bla bla" ]; |
|
117 | - $this->SelectField->setSelectIsMultiple( $other_args ); |
|
118 | - $this->assertTrue( $this->SelectField->getData()["selectismultiple"] ); |
|
116 | + $other_args = ["part_of_multiple" => "bla bla bla"]; |
|
117 | + $this->SelectField->setSelectIsMultiple($other_args); |
|
118 | + $this->assertTrue($this->SelectField->getData()["selectismultiple"]); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | public function testSetSelectIsMultiple_keyExistFalse() { |
122 | 122 | |
123 | - $other_args = [ "Not_part_of_multiple" => "blas blas blas" ]; |
|
124 | - $this->SelectField->setSelectIsMultiple( $other_args ); |
|
125 | - $this->assertFalse( $this->SelectField->getData()["selectismultiple"] ); |
|
123 | + $other_args = ["Not_part_of_multiple" => "blas blas blas"]; |
|
124 | + $this->SelectField->setSelectIsMultiple($other_args); |
|
125 | + $this->assertFalse($this->SelectField->getData()["selectismultiple"]); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | public function testSetSelectTemplate_correctData() { |
129 | 129 | $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]"; |
130 | 130 | $result = "{{#"; |
131 | - $this->SelectField->setSelectTemplate( $input_name ); |
|
131 | + $this->SelectField->setSelectTemplate($input_name); |
|
132 | 132 | |
133 | 133 | $this->assertEquals( |
134 | 134 | $this->SelectField->getData()['selecttemplate'], $result |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function testSetSelectTemplate_wrongData() { |
139 | 139 | $input_name = "Category:Building Complex"; |
140 | 140 | $result = ""; |
141 | - $this->SelectField->setSelectTemplate( $input_name ); |
|
141 | + $this->SelectField->setSelectTemplate($input_name); |
|
142 | 142 | |
143 | 143 | $this->assertEquals( |
144 | 144 | $this->SelectField->getData()['selecttemplate'], $result |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]"; |
150 | 150 | $result = "Part Of Site::@@@@]"; |
151 | 151 | |
152 | - $this->SelectField->setSelectField( $input_name ); |
|
152 | + $this->SelectField->setSelectField($input_name); |
|
153 | 153 | |
154 | 154 | $this->assertEquals( |
155 | 155 | $this->SelectField->getData()['selectfield'], $result |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public function testSetSelectField_wrongData() { |
160 | 160 | $input_name = "Category:Building Complex"; |
161 | 161 | $result = ""; |
162 | - $this->SelectField->setSelectField( $input_name ); |
|
162 | + $this->SelectField->setSelectField($input_name); |
|
163 | 163 | |
164 | 164 | $this->assertNotEquals( |
165 | 165 | $this->SelectField->getData()['selectfield'], $result |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | |
169 | 169 | public function testSetValueTemplate_containsMselectTemplate() { |
170 | 170 | $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]"; |
171 | - $other_args = [ "sametemplate" => "test values" ]; |
|
171 | + $other_args = ["sametemplate" => "test values"]; |
|
172 | 172 | $result = "{{#"; |
173 | - $this->SelectField->setSelectTemplate( $input_name ); |
|
174 | - $this->SelectField->setValueTemplate( $other_args ); |
|
173 | + $this->SelectField->setSelectTemplate($input_name); |
|
174 | + $this->SelectField->setValueTemplate($other_args); |
|
175 | 175 | |
176 | 176 | $this->assertEquals( |
177 | 177 | $this->SelectField->getData()["valuetemplate"], $result |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | |
181 | 181 | public function testSetValueTemplate_containsOtherArgsTemplate() { |
182 | 182 | |
183 | - $other_args = [ "template" => "test values" ]; |
|
183 | + $other_args = ["template" => "test values"]; |
|
184 | 184 | |
185 | - $this->SelectField->setValueTemplate( $other_args ); |
|
185 | + $this->SelectField->setValueTemplate($other_args); |
|
186 | 186 | |
187 | 187 | $this->assertEquals( |
188 | 188 | $this->SelectField->getData()["valuetemplate"], |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | public function testSetValueField() { |
194 | - $other_args = [ "field" => "test values Field" ]; |
|
194 | + $other_args = ["field" => "test values Field"]; |
|
195 | 195 | |
196 | - $this->SelectField->setValueField( $other_args ); |
|
196 | + $this->SelectField->setValueField($other_args); |
|
197 | 197 | |
198 | 198 | $this->assertEquals( |
199 | 199 | $this->SelectField->getData()["valuefield"], $other_args["field"] |
@@ -201,35 +201,35 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | public function testSetSelectRemove_keyExistTrue() { |
204 | - $other_args = [ 'rmdiv' => "Test data" ]; |
|
205 | - $this->SelectField->setSelectRemove( $other_args ); |
|
206 | - $this->assertTrue( $this->SelectField->getData()["selectrm"] ); |
|
204 | + $other_args = ['rmdiv' => "Test data"]; |
|
205 | + $this->SelectField->setSelectRemove($other_args); |
|
206 | + $this->assertTrue($this->SelectField->getData()["selectrm"]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | public function testSetSelectRemove_keyExistFalse() { |
210 | 210 | |
211 | - $other_args = [ "no_rmdiv" => "test data" ]; |
|
212 | - $this->SelectField->setSelectRemove( $other_args ); |
|
213 | - $this->assertFalse( $this->SelectField->getData()["selectrm"] ); |
|
211 | + $other_args = ["no_rmdiv" => "test data"]; |
|
212 | + $this->SelectField->setSelectRemove($other_args); |
|
213 | + $this->assertFalse($this->SelectField->getData()["selectrm"]); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | public function testSetLabel_keyExistTrue() { |
217 | - $other_args = [ 'label' => "Test data" ]; |
|
218 | - $this->SelectField->setLabel( $other_args ); |
|
219 | - $this->assertTrue( $this->SelectField->getData()["label"] ); |
|
217 | + $other_args = ['label' => "Test data"]; |
|
218 | + $this->SelectField->setLabel($other_args); |
|
219 | + $this->assertTrue($this->SelectField->getData()["label"]); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | public function testSetLabel_keyExistFalse() { |
223 | 223 | |
224 | - $other_args = [ "no_label" => "test data" ]; |
|
225 | - $this->SelectField->setLabel( $other_args ); |
|
226 | - $this->assertArrayHasKey( "label", $this->SelectField->getData() ); |
|
227 | - $this->assertFalse( $this->SelectField->getData()["label"] ); |
|
224 | + $other_args = ["no_label" => "test data"]; |
|
225 | + $this->SelectField->setLabel($other_args); |
|
226 | + $this->assertArrayHasKey("label", $this->SelectField->getData()); |
|
227 | + $this->assertFalse($this->SelectField->getData()["label"]); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | public function testSetDelimiter_keyExistTrue() { |
231 | - $other_args = [ "delimiter" => ":" ]; |
|
232 | - $this->SelectField->setDelimiter( $other_args ); |
|
231 | + $other_args = ["delimiter" => ":"]; |
|
232 | + $this->SelectField->setDelimiter($other_args); |
|
233 | 233 | $this->assertEquals( |
234 | 234 | $this->SelectField->getDelimiter(), $other_args["delimiter"] |
235 | 235 | ); |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | |
241 | 241 | public function testSetWgPageFormsListSeparator_keyExistTrue() { |
242 | 242 | |
243 | - $g_args = [ "Global_delimiter" => ";" ]; |
|
244 | - $this->SelectField->setDelimiter( $g_args ); |
|
243 | + $g_args = ["Global_delimiter" => ";"]; |
|
244 | + $this->SelectField->setDelimiter($g_args); |
|
245 | 245 | $this->assertEquals( |
246 | 246 | $this->SelectField->getDelimiter(), $g_args["Global_delimiter"] |
247 | 247 | ); |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | protected function setUp() { |
254 | 254 | parent::setUp(); |
255 | 255 | $this->parser = $GLOBALS['wgParser']; |
256 | - $this->parser->setTitle( Title::newFromText( 'NO TITLE' ) ); |
|
256 | + $this->parser->setTitle(Title::newFromText('NO TITLE')); |
|
257 | 257 | $this->parser->mOptions = new ParserOptions(); |
258 | 258 | $this->parser->resetOutput(); |
259 | 259 | $this->parser->clearState(); |
260 | - $this->SelectField = new SelectField( $this->parser ); |
|
260 | + $this->SelectField = new SelectField($this->parser); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | protected function tearDown() { |
264 | - unset( $this->SelectField ); |
|
264 | + unset($this->SelectField); |
|
265 | 265 | parent::tearDown(); |
266 | 266 | } |
267 | 267 |