You are here

public function ViewsDataTest::testViewsFetchData in Views (for Drupal 7) 8.3

Tests the views_fetch_data function.

See also

views_fetch_data

File

lib/Drupal/views/Tests/ViewsDataTest.php, line 36
Definition of Drupal\views\Tests\ViewsDataTest.

Class

ViewsDataTest
Tests the fetching of views data.

Namespace

Drupal\views\Tests

Code

public function testViewsFetchData() {
  $table_name = 'views_test_data';
  $expected_data = $this
    ->viewsData();
  $data = views_fetch_data($table_name);
  $this
    ->assertEqual($data, $expected_data[$table_name], 'Make sure fetching views data by table works as expected.');
  $data = views_fetch_data();
  $this
    ->assertTrue(isset($data[$table_name]), 'Make sure the views_test_data info appears in the total views data.');
  $this
    ->assertEqual($data[$table_name], $expected_data[$table_name], 'Make sure the views_test_data has the expected values.');
  $data = views_fetch_data(NULL, TRUE);
  $this
    ->assertTrue(isset($data[$table_name]), 'Make sure the views_fetch_data appears in the total views data with reset = TRUE.');
  $this
    ->assertEqual($data[$table_name], $expected_data[$table_name], 'Make sure the views_test_data has the expected values.');
}