3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
8 * Tests the presence of JavaScript at update.php.
13 class UpdatePathTestJavaScriptTest extends UpdatePathTestBase {
18 protected function setDatabaseDumpFiles() {
19 $this->databaseDumpFiles = [
20 __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
25 * Test JavaScript loading at update.php.
27 * @see ::doPreUpdateTests
29 public function testJavaScriptLoading() {
36 protected function doSelectionTest() {
37 // Ensure that at least one JS script has drupalSettings in there.
38 $scripts = $this->xpath('//script');
40 foreach ($scripts as $script) {
41 if (!$script->getAttribute('src')) {
44 // Source is a root-relative URL. Transform it to an absolute URL to allow
45 // file_get_contents() to access the file.
46 $src = preg_replace('#^' . $GLOBALS['base_path'] . '(.*)#i', $GLOBALS['base_url'] . '/' . '${1}', $script->getAttribute('src'));
47 $file_content = file_get_contents($src);
49 if (strpos($file_content, 'window.drupalSettings =') !== FALSE) {
55 $this->assertTrue($found, 'Ensure that the drupalSettingsLoader.js was included in the JS files');