class UpdatePathTestJavaScriptTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest
- 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest
- 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestJavaScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest
Tests the presence of JavaScript at update.php.
@group Update
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\UpdateSystem\UpdatePathTestJavaScriptTest uses \Drupal\Tests\UpdatePathTestTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of UpdatePathTestJavaScriptTest
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdatePathTestJavaScriptTest.php, line 13
Namespace
Drupal\Tests\system\Functional\UpdateSystemView source
class UpdatePathTestJavaScriptTest extends BrowserTestBase {
use UpdatePathTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->ensureUpdatesToRun();
}
/**
* Tests JavaScript loading at update.php.
*
* @see ::doPreUpdateTests
*/
public function testJavaScriptLoading() {
$this->runUpdates();
}
/**
* {@inheritdoc}
*/
protected function doSelectionTest() {
// 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 (strpos($file_content, 'window.drupalSettings =') !== FALSE) {
$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.