@@ -50,6 +50,9 @@ class StructureTest extends \PHPUnit\Framework\TestCase
50
50
*/
51
51
protected $ _structureData ;
52
52
53
+ /**
54
+ * @inheritdoc
55
+ */
53
56
protected function setUp ()
54
57
{
55
58
$ this ->_flyweightFactory = $ this ->getMockBuilder (FlyweightFactory::class)
@@ -82,7 +85,12 @@ protected function setUp()
82
85
);
83
86
}
84
87
85
- public function testGetTabsBuildsSectionTree ()
88
+ /**
89
+ * Verify tabs build section tree
90
+ *
91
+ * @return void
92
+ */
93
+ public function testGetTabsBuildsSectionTree (): void
86
94
{
87
95
$ expected = ['tab1 ' => ['children ' => ['section1 ' => ['tab ' => 'tab1 ' ]]]];
88
96
@@ -108,7 +116,12 @@ public function testGetTabsBuildsSectionTree()
108
116
$ this ->assertEquals ($ this ->_tabIteratorMock , $ model ->getTabs ());
109
117
}
110
118
111
- public function testGetSectionList ()
119
+ /**
120
+ * Verify get section list method
121
+ *
122
+ * @return void
123
+ */
124
+ public function testGetSectionList (): void
112
125
{
113
126
$ expected = [
114
127
'section1_child_id_1 ' => true ,
@@ -152,6 +165,8 @@ public function testGetSectionList()
152
165
}
153
166
154
167
/**
168
+ * Verify Get Element return empty element if element is requested
169
+ *
155
170
* @param string $path
156
171
* @param string $expectedType
157
172
* @param string $expectedId
@@ -174,6 +189,8 @@ public function testGetElementReturnsEmptyElementIfNotExistingElementIsRequested
174
189
}
175
190
176
191
/**
192
+ * Verify get Element return empty by path element if not exist
193
+ *
177
194
* @param string $path
178
195
* @param string $expectedType
179
196
* @param string $expectedId
@@ -196,6 +213,8 @@ public function testGetElementReturnsEmptyByConfigPathElementIfNotExistingElemen
196
213
}
197
214
198
215
/**
216
+ * Verify Element return e,pty element if not exists
217
+ *
199
218
* @param string $expectedType
200
219
* @param string $expectedId
201
220
* @param string $expectedPath
@@ -234,21 +253,33 @@ public function emptyElementDataProvider()
234
253
];
235
254
}
236
255
237
- public function testGetElementReturnsProperElementByPath ()
256
+ /**
257
+ * Verify get element returns proper element by path
258
+ *
259
+ * @return void
260
+ */
261
+ public function testGetElementReturnsProperElementByPath (): void
238
262
{
239
263
$ elementMock = $ this ->getElementPathReturnsProperElementByPath ();
240
264
241
265
$ this ->assertEquals ($ elementMock , $ this ->_model ->getElement ('section_1/group_level_1/field_3 ' ));
242
266
}
243
267
244
- public function testGetElementByConfigPathReturnsProperElementByPath ()
268
+ /**
269
+ * Verify get element by config path return proper path
270
+ *
271
+ * @return void
272
+ */
273
+ public function testGetElementByConfigPathReturnsProperElementByPath (): void
245
274
{
246
275
$ elementMock = $ this ->getElementPathReturnsProperElementByPath ();
247
276
248
277
$ this ->assertEquals ($ elementMock , $ this ->_model ->getElementByConfigPath ('section_1/group_level_1/field_3 ' ));
249
278
}
250
279
251
280
/**
281
+ * Build mock element
282
+ *
252
283
* @return Mock
253
284
*/
254
285
private function getElementPathReturnsProperElementByPath ()
@@ -271,7 +302,12 @@ private function getElementPathReturnsProperElementByPath()
271
302
return $ elementMock ;
272
303
}
273
304
274
- public function testGetElementByPathPartsIfSectionDataIsEmpty ()
305
+ /**
306
+ * Verefy get element by path part
307
+ *
308
+ * @return void
309
+ */
310
+ public function testGetElementByPathPartsIfSectionDataIsEmpty (): void
275
311
{
276
312
$ fieldData = [
277
313
'id ' => 'field_3 ' ,
@@ -342,15 +378,25 @@ public function testGetFirstSectionReturnsFirstAllowedSection()
342
378
$ this ->assertEquals ('currentSection ' , $ this ->_model ->getFirstSection ()->getData ());
343
379
}
344
380
345
- public function testGetElementReturnsProperElementByPathCachesObject ()
381
+ /**
382
+ * Verify get element return element by path caches object
383
+ *
384
+ * @return void
385
+ */
386
+ public function testGetElementReturnsProperElementByPathCachesObject (): void
346
387
{
347
388
$ elementMock = $ this ->getElementReturnsProperElementByPathCachesObject ();
348
389
349
390
$ this ->assertEquals ($ elementMock , $ this ->_model ->getElement ('section_1/group_level_1/field_3 ' ));
350
391
$ this ->assertEquals ($ elementMock , $ this ->_model ->getElement ('section_1/group_level_1/field_3 ' ));
351
392
}
352
393
353
- public function testGetElementByConfigPathReturnsProperElementByPathCachesObject ()
394
+ /**
395
+ * Verify Get Element by id returns proper element
396
+ *
397
+ * @return void
398
+ */
399
+ public function testGetElementByConfigPathReturnsProperElementByPathCachesObject (): void
354
400
{
355
401
$ elementMock = $ this ->getElementReturnsProperElementByPathCachesObject ();
356
402
@@ -393,6 +439,8 @@ public function testGetFieldPathsByAttribute($attributeName, $attributeValue, $p
393
439
}
394
440
395
441
/**
442
+ * DataProvider
443
+ *
396
444
* @return array
397
445
*/
398
446
public function getFieldPathsByAttributeDataProvider ()
@@ -411,33 +459,53 @@ public function getFieldPathsByAttributeDataProvider()
411
459
];
412
460
}
413
461
414
- public function testGetFieldPaths ()
462
+ /**
463
+ * Verify get Fields paths method
464
+ *
465
+ * @dataProvider getFieldPaths
466
+ * @param array $expected
467
+ * @return void
468
+ */
469
+ public function testGetFieldPaths (array $ expected ): void
415
470
{
416
- $ expected = [
417
- 'section/group/field2 ' => [
418
- 'field_2 '
419
- ],
420
- 'field_3 ' => [
421
- 'field_3 ' ,
422
- 'field_3 '
423
- ],
424
- 'field_3_1 ' => [
425
- 'field_3_1 '
426
- ],
427
- 'field_3_1_1 ' => [
428
- 'field_3_1_1 '
429
- ],
430
- 'section/group/field4 ' => [
431
- 'field_4 ' ,
432
- ],
433
- 'field_5 ' => [
434
- 'field_5 ' ,
435
- ],
436
- ];
437
-
438
471
$ this ->assertSame (
439
472
$ expected ,
440
473
$ this ->_model ->getFieldPaths ()
441
474
);
442
475
}
476
+
477
+ /**
478
+ * dataprovider for Field Paths
479
+ *
480
+ * @return array
481
+ */
482
+ public function getFieldPaths (): array
483
+ {
484
+ return [
485
+ [
486
+ [
487
+ 'section/group/field2 ' => [
488
+ 'field_2 '
489
+ ],
490
+ 'field_3 ' => [
491
+ 'field_3 ' ,
492
+ 'field_3 '
493
+ ],
494
+ 'field_3_1 ' => [
495
+ 'field_3_1 '
496
+ ],
497
+ 'field_3_1_1 ' => [
498
+ 'field_3_1_1 '
499
+ ],
500
+ 'section/group/field4 ' => [
501
+ 'field_4 ' ,
502
+ ],
503
+ 'field_5 ' => [
504
+ 'field_5 ' ,
505
+ ],
506
+ 'section_3 ' => ['section_3 ' ]
507
+ ]
508
+ ]
509
+ ];
510
+ }
443
511
}
0 commit comments