Skip to content

Commit 8312d10

Browse files
author
Olga Kopylova
committed
MAGETWO-31732: Blacklisted ComposerTest
- reduced complexity of a test
1 parent 235a660 commit 8312d10

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,7 @@ public function testComponentPathsInRoot()
391391
self::$rootJson,
392392
"If there are any component paths specified, then they must be reflected in 'replace' section"
393393
);
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']);
406395
while (list(, list($component, $path)) = each($flat)) {
407396
$this->assertFileExists(
408397
self::$root . '/' . $path,
@@ -424,4 +413,27 @@ public function testComponentPathsInRoot()
424413
}
425414
}
426415
}
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+
}
427439
}

0 commit comments

Comments
 (0)