An integrity test that searches for references to static files and asserts that they are resolved via fallback @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Definition at line 15 of file StaticFilesTest.php.
testReferencesFromStaticFiles |
( |
|
$area, |
|
|
|
$themePath, |
|
|
|
$locale, |
|
|
|
$module, |
|
|
|
$filePath, |
|
|
|
$absolutePath |
|
) |
| |
Scan references to files from other static files and assert they are correct
The CSS or LESS files may refer to other resources using @import or url() notation We want to check integrity of all these references Note that the references may have syntax specific to the Magento preprocessing subsystem
- Parameters
-
string | $area | |
string | $themePath | |
string | $locale | |
string | $module | |
string | $filePath | |
string | $absolutePath | @dataProvider referencesFromStaticFilesDataProvider |
The LESS library treats the related resources with relative links not in the same way as CSS: when another LESS file is included, it is embedded directly into the resulting document, but the relative paths of related resources are not adjusted accordingly to the new root file. Probably it is a bug of the LESS library.
Definition at line 91 of file StaticFilesTest.php.
95 \
Magento\Framework\View\Url\CssResolver::REGEX_CSS_RELATIVE_URLS,
99 foreach ($matches[1] as $relatedResource) {
100 if (
false !== strpos($relatedResource,
'@')) {
103 list($relatedModule, $relatedPath) =
104 \Magento\Framework\View\Asset\Repository::extractModule($relatedResource);
105 if ($relatedModule) {
106 $fallbackModule = $relatedModule;
108 if (
'less' == pathinfo($filePath, PATHINFO_EXTENSION)) {
115 $this->markTestSkipped(
"Due to LESS library specifics, the '{$relatedResource}' cannot be tested.");
117 $fallbackModule = $module;
121 $staticFile = $this->getStaticFile($area, $themePath, $locale, $relatedPath, $fallbackModule);
122 if (empty($staticFile) && substr($relatedPath, 0, 2) ===
'..') {
124 $path = substr($relatedPath, 2);
126 $rule = $this->simpleFactory->create([
'pattern' => $libDir]);
127 $params = [
'area' => $area,
'theme' => $themePath,
'locale' => $locale];
130 $this->assertNotEmpty(
132 "The related resource cannot be resolved through fallback: '{$relatedResource}'"
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
static getRelatedPath($relativeTo, $path)