Skip to content

Commit 4068a84

Browse files
committed
Merge branch 'MAGETWO-86990' into MPI-PR-2.2.5
2 parents 35c4142 + ec9a76a commit 4068a84

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

dev/tests/integration/testsuite/Magento/Ui/Component/ConfigurationTest.php

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
99
use Magento\Framework\Component\ComponentFile;
10+
use Magento\Framework\Component\ComponentRegistrar;
1011
use Magento\Framework\Component\DirSearch;
12+
use Magento\Framework\Exception\FileSystemException;
1113
use Magento\Framework\Filesystem;
1214
use Magento\Framework\Filesystem\Directory\ReadInterface;
1315
use Magento\TestFramework\Helper\Bootstrap;
1416
use Magento\Ui\Config\Reader\DefinitionMap;
15-
use Magento\Framework\Component\ComponentRegistrar;
1617

18+
/**
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20+
*/
1721
class ConfigurationTest extends \PHPUnit\Framework\TestCase
1822
{
1923
/**
@@ -26,6 +30,11 @@ class ConfigurationTest extends \PHPUnit\Framework\TestCase
2630
*/
2731
private $appDir;
2832

33+
/**
34+
* @var ReadInterface
35+
*/
36+
private $rootDir;
37+
2938
/**
3039
* @var \DOMDocument
3140
*/
@@ -66,9 +75,8 @@ public function setUp()
6675

6776
/** @var Filesystem $filesystem */
6877
$filesystem = $objectManager->create(Filesystem::class);
69-
$this->appDir = $this->isComposerBuilt()
70-
? $filesystem->getDirectoryRead(DirectoryList::ROOT)
71-
: $filesystem->getDirectoryRead(DirectoryList::APP);
78+
$this->appDir = $filesystem->getDirectoryRead(DirectoryList::APP);
79+
$this->rootDir = $filesystem->getDirectoryRead(DirectoryList::ROOT);
7280
}
7381

7482
/**
@@ -86,7 +94,14 @@ public function testConfiguration()
8694
/** @var ComponentFile $file */
8795
foreach ($uiConfigurationFiles as $file) {
8896
$this->currentFile = $file;
89-
$content = $this->appDir->readFile($this->appDir->getRelativePath($file->getFullPath()));
97+
$fullPath = $file->getFullPath();
98+
// by default search files in `app` directory but Magento can be installed via composer
99+
// or some modules can be in `vendor` directory (like bundled extensions)
100+
try {
101+
$content = $this->appDir->readFile($this->appDir->getRelativePath($fullPath));
102+
} catch (FileSystemException $e) {
103+
$content = $this->rootDir->readFile($this->rootDir->getRelativePath($fullPath));
104+
}
90105
$this->assertConfigurationSemantic($this->getDom($content), $result);
91106
}
92107
if (!empty($result)) {
@@ -251,20 +266,4 @@ private function getDom($content = null)
251266
}
252267
return $this->dom;
253268
}
254-
255-
/**
256-
* Check magento modules is in app/code.
257-
*
258-
* @return bool
259-
*/
260-
private function isComposerBuilt()
261-
{
262-
$result = false;
263-
$rootJson = json_decode(file_get_contents(BP . '/composer.json'), true);
264-
if (preg_match('/magento\/project-*/', $rootJson['name']) == 1) {
265-
$result = true;
266-
}
267-
268-
return $result;
269-
}
270269
}

0 commit comments

Comments
 (0)