You are here

function CacheTest::testNoneResultCaching in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/CacheTest.php \Drupal\views\Tests\Plugin\CacheTest::testNoneResultCaching()

Tests no caching.

See also

views_plugin_cache_time

File

core/modules/views/src/Tests/Plugin/CacheTest.php, line 232
Contains \Drupal\views\Tests\Plugin\CacheTest.

Class

CacheTest
Tests pluggable caching for views.

Namespace

Drupal\views\Tests\Plugin

Code

function testNoneResultCaching() {

  // Create a basic result which just 2 results.
  $view = Views::getView('test_cache');
  $view
    ->setDisplay();
  $view->display_handler
    ->overrideOption('cache', array(
    'type' => 'none',
    'options' => array(),
  ));
  $this
    ->executeView($view);

  // Verify the result.
  $this
    ->assertEqual(5, count($view->result), 'The number of returned rows match.');

  // Add another man to the beatles.
  $record = array(
    'name' => 'Rod Davis',
    'age' => 29,
    'job' => 'Banjo',
  );
  db_insert('views_test_data')
    ->fields($record)
    ->execute();

  // The Result changes, because the view is not cached.
  $view = Views::getView('test_cache');
  $view
    ->setDisplay();
  $view->display_handler
    ->overrideOption('cache', array(
    'type' => 'none',
    'options' => array(),
  ));
  $this
    ->executeView($view);

  // Verify the result.
  $this
    ->assertEqual(6, count($view->result), 'The number of returned rows match.');
}