@@ -391,18 +391,7 @@ public function testComponentPathsInRoot()
391
391
self ::$ rootJson ,
392
392
"If there are any component paths specified, then they must be reflected in 'replace' section "
393
393
);
394
- $ flat = [];
395
- foreach (self ::$ rootJson ['extra ' ]['component_paths ' ] as $ key => $ element ) {
396
- if (is_string ($ element )) {
397
- $ flat [] = [$ key , $ element ];
398
- } elseif (is_array ($ element )) {
399
- foreach ($ element as $ path ) {
400
- $ flat [] = [$ key , $ path ];
401
- }
402
- } else {
403
- throw new \Exception ("Unexpected element 'in extra->component_paths' section " );
404
- }
405
- }
394
+ $ flat = $ this ->getFlatPathsInfo (self ::$ rootJson ['extra ' ]['component_paths ' ]);
406
395
while (list (, list ($ component , $ path )) = each ($ flat )) {
407
396
$ this ->assertFileExists (
408
397
self ::$ root . '/ ' . $ path ,
@@ -424,4 +413,27 @@ public function testComponentPathsInRoot()
424
413
}
425
414
}
426
415
}
416
+
417
+ /**
418
+ * @param array $info
419
+ * @return array
420
+ * @throws \Exception
421
+ */
422
+ private function getFlatPathsInfo (array $ info )
423
+ {
424
+ $ flat = [];
425
+ foreach ($ info as $ key => $ element ) {
426
+ if (is_string ($ element )) {
427
+ $ flat [] = [$ key , $ element ];
428
+ } elseif (is_array ($ element )) {
429
+ foreach ($ element as $ path ) {
430
+ $ flat [] = [$ key , $ path ];
431
+ }
432
+ } else {
433
+ throw new \Exception ("Unexpected element 'in extra->component_paths' section " );
434
+ }
435
+ }
436
+
437
+ return $ flat ;
438
+ }
427
439
}
0 commit comments