You are here

public function ViewsDataTest::testCacheCallsWithoutWarmCacheAndGetAllTables in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithoutWarmCacheAndGetAllTables()

Tests the cache calls for all views data without a warm cache.

File

core/modules/views/tests/src/Unit/ViewsDataTest.php, line 561
Contains \Drupal\Tests\views\Unit\ViewsDataTest.

Class

ViewsDataTest
@coversDefaultClass \Drupal\views\ViewsData @group views

Namespace

Drupal\Tests\views\Unit

Code

public function testCacheCallsWithoutWarmCacheAndGetAllTables() {
  $expected_views_data = $this
    ->viewsDataWithProvider();
  $this
    ->setupMockedModuleHandler();

  // Setup a warm cache backend for a single table.
  $this->cacheBackend
    ->expects($this
    ->once())
    ->method('get')
    ->with("views_data:en");
  $this->cacheBackend
    ->expects($this
    ->once())
    ->method('set')
    ->with('views_data:en', $expected_views_data);

  // Initialize the views data cache and repeat with no specified table. This
  // should only load the cache entry for all tables.
  for ($i = 0; $i < 5; $i++) {
    $views_data = $this->viewsData
      ->get();
    $this
      ->assertSame($expected_views_data, $views_data);
  }
}