You are here

function CacheActionsViewsTestCase::testClearViews in Cache Actions 6.2

Same name and namespace in other branches
  1. 7.2 cache_actions.test \CacheActionsViewsTestCase::testClearViews()
  2. 7 cache_actions.test \CacheActionsViewsTestCase::testClearViews()

Test clearing the cache of a view.

File

./cache_actions.test, line 35
This file contains the tests for Cache Actions. All tests depend on the panels, views and rules that are defined by the cache actions test module.

Class

CacheActionsViewsTestCase
Tests for Cache Actions Views.

Code

function testClearViews() {
  drupal_flush_all_caches();

  // Create a node.
  $node = $this
    ->drupalCreateNode();

  // Get the view page.
  $html = $this
    ->drupalGet('cache-actions-test-view');

  // We should see the node title.
  $this
    ->assertText($node->title, t('Title found.'));

  // Do the same for the view that doesn't have a rule that will be triggered.
  $html = $this
    ->drupalGet('cache-actions-test-view-no-cache');
  $this
    ->assertText($node->title, t('Title found.'));
  $node->title = "We have changed the title";

  // Save the changed node.
  node_save($node);

  // Execute the view again. The result should be the same.
  $html = $this
    ->drupalGet('cache-actions-test-view');

  // The node title should have changed since the rule is active.
  $this
    ->assertText($node->title, t('Title found after cached has been cleared'));
  $html = $this
    ->drupalGet('cache-actions-test-view-no-cache');
  $this
    ->assertNOText($node->title, t('Title not found after cached has been cleared'));
}