UpdatePathTestJavaScriptTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\UpdateSystem;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\UpdatePathTestTrait;
class UpdatePathTestJavaScriptTest extends BrowserTestBase {
use UpdatePathTestTrait;
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this
->ensureUpdatesToRun();
}
public function testJavaScriptLoading() {
$this
->runUpdates();
}
protected function doSelectionTest() {
$scripts = $this
->xpath('//script');
$found = FALSE;
foreach ($scripts as $script) {
if (!$script
->getAttribute('src')) {
continue;
}
$src = preg_replace('#^' . $GLOBALS['base_path'] . '(.*)#i', $GLOBALS['base_url'] . '/' . '${1}', $script
->getAttribute('src'));
$file_content = file_get_contents($src);
if (strpos($file_content, 'window.drupalSettings =') !== FALSE) {
$found = TRUE;
break;
}
}
$this
->assertTrue($found, 'Ensure that the drupalSettingsLoader.js was included in the JS files');
}
}