Skip to content
Snippets Groups Projects
Commit 7502e7bc authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1843420 by ACF: Added Change block test variables - block_test_cache()...

Issue #1843420 by ACF: Added Change block test variables - block_test_cache() and block_test_content() to state system.
parent 19276d32
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ function testCachePerRole() {
// Enable our test block. Set some content for it to display.
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalLogin($this->normal_user);
$this->drupalGet('');
$this->assertText($current_content, 'Block content displays.');
......@@ -69,7 +69,7 @@ function testCachePerRole() {
// Change the content, but the cached copy should still be served.
$old_content = $current_content;
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($old_content, 'Block is served from the cache.');
......@@ -82,7 +82,7 @@ function testCachePerRole() {
// Test whether the cached data is served for the correct users.
$old_content = $current_content;
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalLogout();
$this->drupalGet('');
$this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.');
......@@ -106,14 +106,14 @@ function testCachePerRole() {
function testCacheGlobal() {
$this->setCacheMode(DRUPAL_CACHE_GLOBAL);
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($current_content, 'Block content displays.');
$old_content = $current_content;
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalLogout();
$this->drupalGet('user');
......@@ -126,7 +126,7 @@ function testCacheGlobal() {
function testNoCache() {
$this->setCacheMode(DRUPAL_NO_CACHE);
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
// If DRUPAL_NO_CACHE has no effect, the next request would be cached.
$this->drupalGet('');
......@@ -134,7 +134,7 @@ function testNoCache() {
// A cached copy should not be served.
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($current_content, 'DRUPAL_NO_CACHE prevents blocks from being cached.');
}
......@@ -145,7 +145,7 @@ function testNoCache() {
function testCachePerUser() {
$this->setCacheMode(DRUPAL_CACHE_PER_USER);
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalLogin($this->normal_user);
$this->drupalGet('');
......@@ -153,7 +153,7 @@ function testCachePerUser() {
$old_content = $current_content;
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($old_content, 'Block is served from per-user cache.');
......@@ -173,14 +173,14 @@ function testCachePerUser() {
function testCachePerPage() {
$this->setCacheMode(DRUPAL_CACHE_PER_PAGE);
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalGet('node');
$this->assertText($current_content, 'Block content displays on the node page.');
$old_content = $current_content;
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
$this->drupalGet('user');
$this->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.');
......
......@@ -42,7 +42,7 @@ function setUp() {
// Make sure the block has some content so it will appear
$current_content = $this->randomName();
variable_set('block_test_content', $current_content);
state()->set('block_test.content', $current_content);
}
/**
......
......@@ -414,7 +414,7 @@ function testBlockRehash() {
$this->assertEqual($current_caching, DRUPAL_CACHE_PER_ROLE, 'Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.');
// Disable caching for this block.
variable_set('block_test_caching', DRUPAL_NO_CACHE);
state()->set('block_test.caching', DRUPAL_NO_CACHE);
// Flushing all caches should call _block_rehash().
$this->resetAll();
// Verify that the database is updated with the new caching mode.
......
......@@ -19,7 +19,7 @@ function block_test_system_theme_info() {
function block_test_block_info() {
$blocks['test_cache'] = array(
'info' => t('Test block caching'),
'cache' => variable_get('block_test_caching', DRUPAL_CACHE_PER_ROLE),
'cache' => state()->get('block_test.caching') ?: DRUPAL_CACHE_PER_ROLE,
);
$blocks['test_html_id'] = array(
......@@ -32,5 +32,5 @@ function block_test_block_info() {
* Implements hook_block_view().
*/
function block_test_block_view($delta = 0) {
return array('content' => variable_get('block_test_content', ''));
return array('content' => state()->get('block_test.content'));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment