Loading core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ class TestCacheBlock extends BlockBase { * {@inheritdoc} */ public function build() { $content = \Drupal::state()->get('block_test.content'); $content = \Drupal::keyValue('block_test')->get('content'); $build = []; if (!empty($content)) { Loading core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php +2 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ class TestHtmlBlock extends BlockBase { */ public function build() { return [ '#attributes' => \Drupal::state()->get('block_test.attributes'), '#children' => \Drupal::state()->get('block_test.content'), '#attributes' => \Drupal::keyvalue('block_test')->get('attributes'), '#children' => \Drupal::keyValue('block_test')->get('content'), ]; } Loading core/modules/block/tests/src/Functional/BlockCacheTest.php +11 −11 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public function testCachePerRole(): void { // Enable our test block. Set some content for it to display. $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalLogin($this->normalUser); $this->drupalGet(''); $this->assertSession()->pageTextContains($current_content); Loading @@ -93,7 +93,7 @@ public function testCachePerRole(): void { // Change the content, but the cached copy should still be served. $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet(''); $this->assertSession()->pageTextContains($old_content); Loading @@ -107,7 +107,7 @@ public function testCachePerRole(): void { // Test whether the cached data is served for the correct users. $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalLogout(); $this->drupalGet(''); // Anonymous user does not see content cached per-role for normal user. Loading Loading @@ -138,14 +138,14 @@ public function testCachePermissions(): void { \Drupal::state()->set('block_test.cache_contexts', []); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet(''); $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); // Block content served from cache. $this->drupalGet('user'); Loading @@ -164,7 +164,7 @@ public function testNoCache(): void { \Drupal::state()->set('block_test.cache_max_age', 0); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); // If max_age = 0 has no effect, the next request would be cached. $this->drupalGet(''); Loading @@ -172,7 +172,7 @@ public function testNoCache(): void { // A cached copy should not be served. $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet(''); // Maximum age of zero prevents blocks from being cached. $this->assertSession()->pageTextContains($current_content); Loading @@ -185,7 +185,7 @@ public function testCachePerUser(): void { \Drupal::state()->set('block_test.cache_contexts', ['user']); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalLogin($this->normalUser); $this->drupalGet(''); Loading @@ -193,7 +193,7 @@ public function testCachePerUser(): void { $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); // Block is served from per-user cache. $this->drupalGet(''); Loading @@ -217,14 +217,14 @@ public function testCachePerPage(): void { \Drupal::state()->set('block_test.cache_contexts', ['url']); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet('test-page'); $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet('user'); $this->assertSession()->statusCodeEquals(200); Loading core/modules/block/tests/src/Functional/BlockHtmlTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,8 @@ protected function setUp(): void { ])); // Enable the test_html block, to test HTML ID and attributes. \Drupal::state()->set('block_test.attributes', ['data-custom-attribute' => 'foo']); \Drupal::state()->set('block_test.content', $this->randomMachineName()); \Drupal::keyValue('block_test')->set('attributes', ['data-custom-attribute' => 'foo']); \Drupal::keyValue('block_test')->set('content', $this->randomMachineName()); $this->drupalPlaceBlock('test_html', ['id' => 'test_html_block']); // Enable a menu block, to test more complicated HTML. Loading core/modules/block/tests/src/Functional/BlockXssTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ public function testXssInTitle(): void { $this->container->get('module_installer')->install(['block_test']); $this->drupalPlaceBlock('test_xss_title', ['label' => '<script>alert("XSS label");</script>']); \Drupal::state()->set('block_test.content', $this->randomMachineName()); \Drupal::keyValue('block_test')->set('content', $this->randomMachineName()); $this->drupalGet(''); // Check that the block title was properly sanitized when rendered. $this->assertSession()->responseNotContains('<script>alert("XSS label");</script>'); Loading Loading
core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ class TestCacheBlock extends BlockBase { * {@inheritdoc} */ public function build() { $content = \Drupal::state()->get('block_test.content'); $content = \Drupal::keyValue('block_test')->get('content'); $build = []; if (!empty($content)) { Loading
core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php +2 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ class TestHtmlBlock extends BlockBase { */ public function build() { return [ '#attributes' => \Drupal::state()->get('block_test.attributes'), '#children' => \Drupal::state()->get('block_test.content'), '#attributes' => \Drupal::keyvalue('block_test')->get('attributes'), '#children' => \Drupal::keyValue('block_test')->get('content'), ]; } Loading
core/modules/block/tests/src/Functional/BlockCacheTest.php +11 −11 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public function testCachePerRole(): void { // Enable our test block. Set some content for it to display. $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalLogin($this->normalUser); $this->drupalGet(''); $this->assertSession()->pageTextContains($current_content); Loading @@ -93,7 +93,7 @@ public function testCachePerRole(): void { // Change the content, but the cached copy should still be served. $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet(''); $this->assertSession()->pageTextContains($old_content); Loading @@ -107,7 +107,7 @@ public function testCachePerRole(): void { // Test whether the cached data is served for the correct users. $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalLogout(); $this->drupalGet(''); // Anonymous user does not see content cached per-role for normal user. Loading Loading @@ -138,14 +138,14 @@ public function testCachePermissions(): void { \Drupal::state()->set('block_test.cache_contexts', []); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet(''); $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); // Block content served from cache. $this->drupalGet('user'); Loading @@ -164,7 +164,7 @@ public function testNoCache(): void { \Drupal::state()->set('block_test.cache_max_age', 0); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); // If max_age = 0 has no effect, the next request would be cached. $this->drupalGet(''); Loading @@ -172,7 +172,7 @@ public function testNoCache(): void { // A cached copy should not be served. $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet(''); // Maximum age of zero prevents blocks from being cached. $this->assertSession()->pageTextContains($current_content); Loading @@ -185,7 +185,7 @@ public function testCachePerUser(): void { \Drupal::state()->set('block_test.cache_contexts', ['user']); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalLogin($this->normalUser); $this->drupalGet(''); Loading @@ -193,7 +193,7 @@ public function testCachePerUser(): void { $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); // Block is served from per-user cache. $this->drupalGet(''); Loading @@ -217,14 +217,14 @@ public function testCachePerPage(): void { \Drupal::state()->set('block_test.cache_contexts', ['url']); $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet('test-page'); $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); \Drupal::keyValue('block_test')->set('content', $current_content); $this->drupalGet('user'); $this->assertSession()->statusCodeEquals(200); Loading
core/modules/block/tests/src/Functional/BlockHtmlTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,8 @@ protected function setUp(): void { ])); // Enable the test_html block, to test HTML ID and attributes. \Drupal::state()->set('block_test.attributes', ['data-custom-attribute' => 'foo']); \Drupal::state()->set('block_test.content', $this->randomMachineName()); \Drupal::keyValue('block_test')->set('attributes', ['data-custom-attribute' => 'foo']); \Drupal::keyValue('block_test')->set('content', $this->randomMachineName()); $this->drupalPlaceBlock('test_html', ['id' => 'test_html_block']); // Enable a menu block, to test more complicated HTML. Loading
core/modules/block/tests/src/Functional/BlockXssTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ public function testXssInTitle(): void { $this->container->get('module_installer')->install(['block_test']); $this->drupalPlaceBlock('test_xss_title', ['label' => '<script>alert("XSS label");</script>']); \Drupal::state()->set('block_test.content', $this->randomMachineName()); \Drupal::keyValue('block_test')->set('content', $this->randomMachineName()); $this->drupalGet(''); // Check that the block title was properly sanitized when rendered. $this->assertSession()->responseNotContains('<script>alert("XSS label");</script>'); Loading