class LegacyStorageTest
Same name and namespace in other branches
- 11.x core/themes/default_admin/tests/src/FunctionalJavascript/LegacyStorageTest.php \Drupal\Tests\default_admin\FunctionalJavascript\LegacyStorageTest
Tests migration of inherited browser storage keys.
Attributes
#[Group('default_admin')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\ExtensionListTestTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\default_admin\FunctionalJavascript\LegacyStorageTest extends \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\ExtensionListTestTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of LegacyStorageTest
File
-
core/
themes/ default_admin/ tests/ src/ FunctionalJavascript/ LegacyStorageTest.php, line 14
Namespace
Drupal\Tests\default_admin\FunctionalJavascriptView source
final class LegacyStorageTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'default_admin';
/**
* Tests that legacy values migrate without replacing newer values.
*/
public function testLegacyStorageMigration() : void {
$this->drupalGet('<front>');
$this->getSession()
->executeScript(<<<'JS'
localStorage.setItem('GinDarkMode', 'true');
localStorage.setItem('Drupal.gin.dark_mode', 'true');
localStorage.setItem('GinSidebarOpen', 'true');
localStorage.setItem('Drupal.gin.toolbarExpanded', 'false');
localStorage.setItem('Drupal.gin.sidebarExpanded.mobile', 'true');
localStorage.setItem('Drupal.gin.sidebarExpanded.desktop', 'false');
localStorage.setItem('Drupal.gin.sidebarWidth', '320px');
localStorage.setItem('Drupal.defaultAdmin.sidebarWidth', '400px');
JS);
$this->getSession()
->reload();
$expected = [
'GinDarkMode' => NULL,
'Drupal.gin.dark_mode' => NULL,
'GinSidebarOpen' => NULL,
'Drupal.gin.toolbarExpanded' => NULL,
'Drupal.gin.sidebarExpanded.mobile' => NULL,
'Drupal.gin.sidebarExpanded.desktop' => NULL,
'Drupal.gin.sidebarWidth' => NULL,
'Drupal.navigation.sidebarExpanded' => 'true',
'Drupal.defaultAdmin.sidebarExpanded.mobile' => 'true',
'Drupal.defaultAdmin.sidebarExpanded.desktop' => 'false',
'Drupal.defaultAdmin.sidebarWidth' => '400px',
];
foreach ($expected as $key => $value) {
$encoded_key = json_encode($key, JSON_THROW_ON_ERROR);
$encoded_value = json_encode($value, JSON_THROW_ON_ERROR);
$condition = "localStorage.getItem({$encoded_key}) === {$encoded_value}";
$this->assertJsCondition($condition);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.