function ViewsDataTest::testCacheCallsWithWarmCacheAndGetAllTables

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithWarmCacheAndGetAllTables()
  2. 8.9.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithWarmCacheAndGetAllTables()
  3. 10 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithWarmCacheAndGetAllTables()

Tests the cache calls for all views data.

Warm cache:

  • all tables

File

core/modules/views/tests/src/Unit/ViewsDataTest.php, line 574

Class

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

Namespace

Drupal\Tests\views\Unit

Code

public function testCacheCallsWithWarmCacheAndGetAllTables() : void {
    $expected_views_data = $this->viewsDataWithProvider();
    $this->moduleHandler
        ->expects($this->never())
        ->method('invokeAllWith');
    // Setup a warm cache backend for a single table.
    $this->cacheBackend
        ->expects($this->once())
        ->method('get')
        ->with("views_data:en")
        ->willReturn((object) [
        'data' => $expected_views_data,
    ]);
    $this->cacheBackend
        ->expects($this->never())
        ->method('set');
    // 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
            ->getAll();
        $this->assertSame($expected_views_data, $views_data);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.