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