function UpdatePathTestJavaScriptTest::doSelectionTest
Same name in other branches
- 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest::doSelectionTest()
- 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest::doSelectionTest()
- 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest::doSelectionTest()
Overrides UpdatePathTestTrait::doSelectionTest
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdatePathTestJavaScriptTest.php, line 43
Class
- UpdatePathTestJavaScriptTest
- Tests the presence of JavaScript at update.php.
Namespace
Drupal\Tests\system\Functional\UpdateSystemCode
protected function doSelectionTest() : void {
// Ensure that at least one JS script has drupalSettings in there.
$scripts = $this->xpath('//script');
$found = FALSE;
foreach ($scripts as $script) {
if (!$script->getAttribute('src')) {
continue;
}
// Source is a root-relative URL. Transform it to an absolute URL to allow
// file_get_contents() to access the file.
$src = preg_replace('#^' . $GLOBALS['base_path'] . '(.*)#i', $GLOBALS['base_url'] . '/' . '${1}', $script->getAttribute('src'));
$file_content = file_get_contents($src);
if (str_contains($file_content, 'window.drupalSettings =')) {
$found = TRUE;
break;
}
}
$this->assertTrue($found, 'Ensure that the drupalSettingsLoader.js was included in the JS files');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.