public function ViewsDataTest::testCacheCallsWithSameTableMultipleTimesAndWarmCache in Drupal 8
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\UnitCode
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);
}
}