You are here

protected function CacheTest::getBasicView in Views (for Drupal 7) 8.3

Build and return a basic view of the views_test_data table.

Return value

Drupal\views\ViewExecutable

Overrides ViewTestBase::getBasicView

File

lib/Drupal/views/Tests/Plugin/CacheTest.php, line 38
Definition of Drupal\views\Tests\Plugin\CacheTest.

Class

CacheTest
Basic test for pluggable caching.

Namespace

Drupal\views\Tests\Plugin

Code

protected function getBasicView() {

  // Create the basic view.
  $view = $this
    ->createViewFromConfig('test_view');
  $view->storage
    ->addDisplay('default');
  $view->storage->base_table = 'views_test_data';

  // Set up the fields we need.
  $display = $view->storage
    ->newDisplay('default', 'Master', 'default');
  $display
    ->overrideOption('fields', array(
    'id' => array(
      'id' => 'id',
      'table' => 'views_test_data',
      'field' => 'id',
      'relationship' => 'none',
    ),
    'name' => array(
      'id' => 'name',
      'table' => 'views_test_data',
      'field' => 'name',
      'relationship' => 'none',
    ),
    'age' => array(
      'id' => 'age',
      'table' => 'views_test_data',
      'field' => 'age',
      'relationship' => 'none',
    ),
  ));

  // Set up the sort order.
  $display
    ->overrideOption('sorts', array(
    'id' => array(
      'order' => 'ASC',
      'id' => 'id',
      'table' => 'views_test_data',
      'field' => 'id',
      'relationship' => 'none',
    ),
  ));
  return $view;
}