function ViewsDataTest::testCacheCallsWithSameTableMultipleTimesAndWarmCache
Same name in other branches
- 9 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithSameTableMultipleTimesAndWarmCache()
- 8.9.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithSameTableMultipleTimesAndWarmCache()
- 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.
Warm cache:
- all tables
- views_test_data
File
-
core/
modules/ views/ tests/ src/ Unit/ ViewsDataTest.php, line 413
Class
- ViewsDataTest
- @coversDefaultClass \Drupal\views\ViewsData @group views
Namespace
Drupal\Tests\views\UnitCode
public function testCacheCallsWithSameTableMultipleTimesAndWarmCache() : 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:views_test_data:en')
->willReturn((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.