Completed
Pull Request — master (#91)
by
unknown
18:56
created
tests/phpunit/Unit/SemanticFormsSelectInputTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 		$isMandatory = false;
26 26
 		$isDisabled = false;
27 27
 
28
-		$otherArgs = [ 'template' => 'Foo', 'field' => '',
29
-		                    'function' => 'Bar', 'is_list' => true ];
28
+		$otherArgs = ['template' => 'Foo', 'field' => '',
29
+		                    'function' => 'Bar', 'is_list' => true];
30 30
 
31
-		$parserOutput = $this->getMockBuilder( '\ParserOutput' )
31
+		$parserOutput = $this->getMockBuilder('\ParserOutput')
32 32
 			->disableOriginalConstructor()->getMock();
33 33
 
34
-		$parser = $this->getMockBuilder( '\Parser' )
34
+		$parser = $this->getMockBuilder('\Parser')
35 35
 			->disableOriginalConstructor()->getMock();
36 36
 
37
-		$parser->expects( $this->any() )->method( 'getOutput' )->will(
38
-				$this->returnValue( $parserOutput )
37
+		$parser->expects($this->any())->method('getOutput')->will(
38
+				$this->returnValue($parserOutput)
39 39
 			);
40 40
 		$this->SFSInput = new SemanticFormsSelectInput(
41 41
 			$value, $inputName, $isMandatory, $isDisabled, $otherArgs
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	protected function tearDown(): void {
46
-		unset( $this->SelectField );
46
+		unset($this->SelectField);
47 47
 		parent::tearDown();
48 48
 	}
49 49
 
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 	public function testGetParameters() {
72 72
 
73
-		$this->assertIsArray( $this->SFSInput->getParameters() );
73
+		$this->assertIsArray($this->SFSInput->getParameters());
74 74
 	}
75 75
 
76 76
 
77 77
 	public function testGetResourceModuleNames() {
78
-		$rsmn = [ 'ext.sf_select.scriptselect' ];
78
+		$rsmn = ['ext.sf_select.scriptselect'];
79 79
 
80
-		$this->assertEquals( $rsmn, $this->SFSInput->getResourceModuleNames() );
80
+		$this->assertEquals($rsmn, $this->SFSInput->getResourceModuleNames());
81 81
 	}
82 82
 
83 83
 }
Please login to merge, or discard this patch.
tests/phpunit/Unit/SelectFieldTest.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 class SelectFieldTest extends \PHPUnit_Framework_TestCase {
24 24
 	private $selectField;
25 25
 	
26
-	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' ];
26
+	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 27
 	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";
28
-	private $other_args_query_unparametrized = [ 'query' => '((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ];
29
-	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' ];
28
+	private $other_args_query_unparametrized = ['query' => '((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500'];
29
+	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'];
30 30
 	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}}';
31
-	private $other_args_function_unparametrized = [ 'function' => 'ask:((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~@@;link~none;headers~hide;limit~500' ];
31
+	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 32
 
33 33
 	public function testCanConstruct() {
34 34
 
35
-		$this->assertInstanceOf( '\SFS\SelectField', $this->selectField );
35
+		$this->assertInstanceOf('\SFS\SelectField', $this->selectField);
36 36
 	}
37 37
 
38 38
 	public function testProcessParameters_Query() {
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			"", $this->other_args_query_parametrized
42 42
 		);
43 43
 		$this->assertTrue(
44
-			array_key_exists( "query", $this->other_args_query_parametrized )
44
+			array_key_exists("query", $this->other_args_query_parametrized)
45 45
 		);
46 46
 	}
47 47
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function testParametrized_setQuery() {
59 59
 
60
-		$this->selectField->setQuery( $this->other_args_query_parametrized );
60
+		$this->selectField->setQuery($this->other_args_query_parametrized);
61 61
 
62 62
 		$this->assertEquals(
63 63
 			$this->expected_result_parametrized_setQuery,
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 			$was_replaced
77 77
 		);
78 78
 
79
-		$this->assertTrue( count( $was_remove[0] ) == 0 );
80
-		$this->assertTrue( count( $was_replaced[0] ) > 0 );
79
+		$this->assertTrue(count($was_remove[0]) == 0);
80
+		$this->assertTrue(count($was_replaced[0]) > 0);
81 81
 	}
82 82
 
83 83
 	public function testUnparametrized_setQuery() {
84 84
 
85
-		$this->selectField->setQuery( $this->other_args_query_unparametrized );
85
+		$this->selectField->setQuery($this->other_args_query_unparametrized);
86 86
 
87
-		$this->assertTrue( $this->selectField->getValues() !== null );
88
-		$this->assertTrue( $this->selectField->hasStaticValues() );
87
+		$this->assertTrue($this->selectField->getValues() !== null);
88
+		$this->assertTrue($this->selectField->hasStaticValues());
89 89
 	}
90 90
 
91 91
 	public function testParametrized_setFunction() {
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
 			$this->other_args_function_unparametrized
108 108
 		);
109 109
 
110
-		$this->assertTrue( $this->selectField->hasStaticValues() );
110
+		$this->assertTrue($this->selectField->hasStaticValues());
111 111
 	}
112 112
 
113 113
 	public function testSetSelectIsMultiple_keyExistTrue() {
114
-		$other_args = [ "part_of_multiple" => "bla bla bla" ];
115
-		$this->selectField->setSelectIsMultiple( $other_args );
116
-		$this->assertTrue( $this->selectField->getData()["selectismultiple"] );
114
+		$other_args = ["part_of_multiple" => "bla bla bla"];
115
+		$this->selectField->setSelectIsMultiple($other_args);
116
+		$this->assertTrue($this->selectField->getData()["selectismultiple"]);
117 117
 	}
118 118
 
119 119
 	public function testSetSelectIsMultiple_keyExistFalse() {
120 120
 
121
-		$other_args = [ "Not_part_of_multiple" => "blas blas blas" ];
122
-		$this->selectField->setSelectIsMultiple( $other_args );
123
-		$this->assertFalse( $this->selectField->getData()["selectismultiple"] );
121
+		$other_args = ["Not_part_of_multiple" => "blas blas blas"];
122
+		$this->selectField->setSelectIsMultiple($other_args);
123
+		$this->assertFalse($this->selectField->getData()["selectismultiple"]);
124 124
 	}
125 125
 
126 126
 	public function testSetSelectTemplate_correctData() {
127 127
 		$input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]";
128 128
 		$result = "{{#";
129
-		$this->selectField->setSelectTemplate( $input_name );
129
+		$this->selectField->setSelectTemplate($input_name);
130 130
 
131 131
 		$this->assertEquals(
132 132
 			$this->selectField->getData()['selecttemplate'], $result
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	public function testSetSelectTemplate_wrongData() {
137 137
 		$input_name = "Category:Building Complex";
138 138
 		$result = "";
139
-		$this->selectField->setSelectTemplate( $input_name );
139
+		$this->selectField->setSelectTemplate($input_name);
140 140
 
141 141
 		$this->assertEquals(
142 142
 			$this->selectField->getData()['selecttemplate'], $result
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		$input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]";
148 148
 		$result = "Part Of Site::@@@@]";
149 149
 
150
-		$this->selectField->setSelectField( $input_name );
150
+		$this->selectField->setSelectField($input_name);
151 151
 
152 152
 		$this->assertEquals(
153 153
 			$this->selectField->getData()['selectfield'], $result
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	public function testSetSelectField_wrongData() {
158 158
 		$input_name = "Category:Building Complex";
159 159
 		$result = "";
160
-		$this->selectField->setSelectField( $input_name );
160
+		$this->selectField->setSelectField($input_name);
161 161
 
162 162
 		$this->assertNotEquals(
163 163
 			$this->selectField->getData()['selectfield'], $result
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 
167 167
 	public function testSetValueTemplate_containsMselectTemplate() {
168 168
 		$input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]";
169
-		$other_args = [ "sametemplate" => "test values" ];
169
+		$other_args = ["sametemplate" => "test values"];
170 170
 		$result = "{{#";
171
-		$this->selectField->setSelectTemplate( $input_name );
172
-		$this->selectField->setValueTemplate( $other_args );
171
+		$this->selectField->setSelectTemplate($input_name);
172
+		$this->selectField->setValueTemplate($other_args);
173 173
 
174 174
 		$this->assertEquals(
175 175
 			$this->selectField->getData()["valuetemplate"], $result
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 
179 179
 	public function testSetValueTemplate_containsOtherArgsTemplate() {
180 180
 
181
-		$other_args = [ "template" => "test values" ];
181
+		$other_args = ["template" => "test values"];
182 182
 
183
-		$this->selectField->setValueTemplate( $other_args );
183
+		$this->selectField->setValueTemplate($other_args);
184 184
 
185 185
 		$this->assertEquals(
186 186
 			$this->selectField->getData()["valuetemplate"],
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 	}
190 190
 
191 191
 	public function testSetValueField() {
192
-		$other_args = [ "field" => "test values Field" ];
192
+		$other_args = ["field" => "test values Field"];
193 193
 
194
-		$this->selectField->setValueField( $other_args );
194
+		$this->selectField->setValueField($other_args);
195 195
 
196 196
 		$this->assertEquals(
197 197
 			$this->selectField->getData()["valuefield"], $other_args["field"]
@@ -199,35 +199,35 @@  discard block
 block discarded – undo
199 199
 	}
200 200
 
201 201
 	public function testSetSelectRemove_keyExistTrue() {
202
-		$other_args = [ 'rmdiv' => "Test data" ];
203
-		$this->selectField->setSelectRemove( $other_args );
204
-		$this->assertTrue( $this->selectField->getData()["selectrm"] );
202
+		$other_args = ['rmdiv' => "Test data"];
203
+		$this->selectField->setSelectRemove($other_args);
204
+		$this->assertTrue($this->selectField->getData()["selectrm"]);
205 205
 	}
206 206
 
207 207
 	public function testSetSelectRemove_keyExistFalse() {
208 208
 
209
-		$other_args = [ "no_rmdiv" => "test data" ];
210
-		$this->selectField->setSelectRemove( $other_args );
211
-		$this->assertFalse( $this->selectField->getData()["selectrm"] );
209
+		$other_args = ["no_rmdiv" => "test data"];
210
+		$this->selectField->setSelectRemove($other_args);
211
+		$this->assertFalse($this->selectField->getData()["selectrm"]);
212 212
 	}
213 213
 
214 214
 	public function testSetLabel_keyExistTrue() {
215
-		$other_args = [ 'label' => "Test data" ];
216
-		$this->selectField->setLabel( $other_args );
217
-		$this->assertTrue( $this->selectField->getData()["label"] );
215
+		$other_args = ['label' => "Test data"];
216
+		$this->selectField->setLabel($other_args);
217
+		$this->assertTrue($this->selectField->getData()["label"]);
218 218
 	}
219 219
 
220 220
 	public function testSetLabel_keyExistFalse() {
221 221
 
222
-		$other_args = [ "no_label" => "test data" ];
223
-		$this->selectField->setLabel( $other_args );
224
-		$this->assertArrayHasKey( "label", $this->selectField->getData() );
225
-		$this->assertFalse( $this->selectField->getData()["label"] );
222
+		$other_args = ["no_label" => "test data"];
223
+		$this->selectField->setLabel($other_args);
224
+		$this->assertArrayHasKey("label", $this->selectField->getData());
225
+		$this->assertFalse($this->selectField->getData()["label"]);
226 226
 	}
227 227
 
228 228
 	public function testSetDelimiter_keyExistTrue() {
229
-		$other_args = [ "delimiter" => ":" ];
230
-		$this->selectField->setDelimiter( $other_args );
229
+		$other_args = ["delimiter" => ":"];
230
+		$this->selectField->setDelimiter($other_args);
231 231
 		$this->assertEquals(
232 232
 			$this->selectField->getDelimiter(), $other_args["delimiter"]
233 233
 		);
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 
239 239
 	public function testSetWgPageFormsListSeparator_keyExistTrue() {
240 240
 
241
-		$g_args = [ "delimiter" => ";" ];
242
-		$this->selectField->setDelimiter( $g_args );
241
+		$g_args = ["delimiter" => ";"];
242
+		$this->selectField->setDelimiter($g_args);
243 243
 		$this->assertEquals(
244 244
 			$this->selectField->getDelimiter(), $g_args["delimiter"]
245 245
 		);
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
 		parent::setUp();
253 253
 		$parser = MediaWikiServices::getInstance()->getParser();
254 254
 		$parser->setOutputType(Parser::OT_HTML);
255
-		$parser->setTitle( Title::newFromText( 'NO TITLE' ) );
255
+		$parser->setTitle(Title::newFromText('NO TITLE'));
256 256
 		$parser->mOptions = new ParserOptions();
257 257
 		$parser->resetOutput();
258 258
 		$parser->clearState();
259
-		$this->selectField = new SelectField( $parser );
259
+		$this->selectField = new SelectField($parser);
260 260
 	}
261 261
 
262 262
 	protected function tearDown(): void {
263
-		unset( $this->selectField );
263
+		unset($this->selectField);
264 264
 		parent::tearDown();
265 265
 	}
266 266
 
Please login to merge, or discard this patch.
tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	) {
66 66
 
67 67
 		$parameters = [ 'approach' => 'smw', 'query' => 'foo, baa, gaah',
68
-		                     'sep'      => ',' ];
68
+							 'sep'      => ',' ];
69 69
 
70 70
 		$this->assertIsObject(
71 71
 			$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	public function testSetDebugFlag_doProcessQueryFor() {
89 89
 		$this->ApiSFSRP->setDebugFlag( true );
90 90
 		$parameters = [ 'approach' => 'smw', 'query' => 'my Query,query2',
91
-		                     'sep'      => ',' ];
91
+							 'sep'      => ',' ];
92 92
 
93 93
 		$this->assertIsObject(
94 94
 			$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 
25 25
 	protected function setUp(): void {
26 26
 		parent::setUp();
27
-		$parser = $this->getMockBuilder( '\Parser' )
27
+		$parser = $this->getMockBuilder('\Parser')
28 28
 			->disableOriginalConstructor()->getMock();
29
-		$this->ApiSFSRP = new ApiSemanticFormsSelectRequestProcessor( $parser );
29
+		$this->ApiSFSRP = new ApiSemanticFormsSelectRequestProcessor($parser);
30 30
 	}
31 31
 
32 32
 	protected function tearDown(): void {
33
-		unset( $this->ApiSFSRP );
33
+		unset($this->ApiSFSRP);
34 34
 		parent::tearDown();
35 35
 	}
36 36
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$parameters = [];
46 46
 
47
-		$this->expectException( 'InvalidArgumentException' );
47
+		$this->expectException('InvalidArgumentException');
48 48
 		$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
49 49
 			$parameters
50 50
 		);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 	public function testJsonResultValuesFromRequestParameters() {
54 54
 
55
-		$parameters = [ 'query' => 'foo', 'sep' => ',' ];
55
+		$parameters = ['query' => 'foo', 'sep' => ','];
56 56
 
57 57
 		$this->assertIsObject(
58 58
 			$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	public function testJsonResultValuesFromRequestParameters_doProcessQueryFor(
65 65
 	) {
66 66
 
67
-		$parameters = [ 'approach' => 'smw', 'query' => 'foo, baa, gaah',
68
-		                     'sep'      => ',' ];
67
+		$parameters = ['approach' => 'smw', 'query' => 'foo, baa, gaah',
68
+		                     'sep'      => ','];
69 69
 
70 70
 		$this->assertIsObject(
71 71
 			$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	}
76 76
 
77 77
 	public function testSetDebugFlag() {
78
-		$this->ApiSFSRP->setDebugFlag( true );
79
-		$parameters = [ 'query' => 'foo , function', 'sep' => ',' ];
78
+		$this->ApiSFSRP->setDebugFlag(true);
79
+		$parameters = ['query' => 'foo , function', 'sep' => ','];
80 80
 
81 81
 		$this->assertIsObject(
82 82
 			$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	public function testSetDebugFlag_doProcessQueryFor() {
89
-		$this->ApiSFSRP->setDebugFlag( true );
90
-		$parameters = [ 'approach' => 'smw', 'query' => 'my Query,query2',
91
-		                     'sep'      => ',' ];
89
+		$this->ApiSFSRP->setDebugFlag(true);
90
+		$parameters = ['approach' => 'smw', 'query' => 'my Query,query2',
91
+		                     'sep'      => ','];
92 92
 
93 93
 		$this->assertIsObject(
94 94
 			$this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	public function testGetFormattedValuesFrom() {
101 101
 		$sep = ",";
102 102
 		$values = "my Query,query2";
103
-		$result = [ "", "my Query", "query2" ];
103
+		$result = ["", "my Query", "query2"];
104 104
 		$formattedValues = $this->invokeMethod(
105
-			$this->ApiSFSRP, 'getFormattedValuesFrom', [ $sep, $values ]
105
+			$this->ApiSFSRP, 'getFormattedValuesFrom', [$sep, $values]
106 106
 		);
107
-		$this->assertEquals( $result, $formattedValues );
107
+		$this->assertEquals($result, $formattedValues);
108 108
 	}
109 109
 
110 110
 	/**
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return mixed Method return.
118 118
 	 */
119
-	public function invokeMethod( &$object, $methodName,
119
+	public function invokeMethod(&$object, $methodName,
120 120
 		array $parameters = []
121 121
 	) {
122
-		$reflection = new \ReflectionClass( get_class( $object ) );
123
-		$method = $reflection->getMethod( $methodName );
124
-		$method->setAccessible( true );
122
+		$reflection = new \ReflectionClass(get_class($object));
123
+		$method = $reflection->getMethod($methodName);
124
+		$method->setAccessible(true);
125 125
 
126
-		return $method->invokeArgs( $object, $parameters );
126
+		return $method->invokeArgs($object, $parameters);
127 127
 	}
128 128
 
129 129
 
Please login to merge, or discard this patch.