function ViewsDataTest::testCacheCallsWithSameTableMultipleTimesAndWarmCache

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

Tests the cache calls for a single table and warm cache for:

  • all tables
  • views_test_data

File

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

Class

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

Namespace

Drupal\Tests\views\Unit

Code

public function testCacheCallsWithSameTableMultipleTimesAndWarmCache() {
    $expected_views_data = $this->viewsDataWithProvider();
    $this->moduleHandler
        ->expects($this->never())
        ->method('getImplementations');
    // Setup a warm cache backend for a single table.
    $this->cacheBackend
        ->expects($this->once())
        ->method('get')
        ->with('views_data:views_test_data:en')
        ->will($this->returnValue((object) [
        'data' => $expected_views_data['views_test_data'],
    ]));
    $this->cacheBackend
        ->expects($this->never())
        ->method('set');
    // We have a warm cache now, so this will only request the tables-specific
    // cache entry and return that.
    for ($i = 0; $i < 5; $i++) {
        $views_data = $this->viewsData
            ->get('views_test_data');
        $this->assertSame($expected_views_data['views_test_data'], $views_data);
    }
}

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