function ViewsDataTest::testCacheCallsWithoutWarmCacheAndGetMultipleTables
Same name in other branches
- 8.9.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithoutWarmCacheAndGetMultipleTables()
- 10 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithoutWarmCacheAndGetMultipleTables()
- 11.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithoutWarmCacheAndGetMultipleTables()
Tests the cache calls for multiple tables without warm caches.
@covers ::get
File
-
core/
modules/ views/ tests/ src/ Unit/ ViewsDataTest.php, line 583
Class
- ViewsDataTest
- @coversDefaultClass \Drupal\views\ViewsData @group views
Namespace
Drupal\Tests\views\UnitCode
public function testCacheCallsWithoutWarmCacheAndGetMultipleTables() {
$expected_views_data = $this->viewsDataWithProvider();
$table_name = 'views_test_data';
$table_name_2 = 'views_test_data_2';
// Setup a warm cache backend for all table data, but not single tables.
$this->cacheBackend
->expects($this->exactly(3))
->method('get')
->withConsecutive([
"views_data:{$table_name}:en",
], [
'views_data:en',
], [
"views_data:{$table_name_2}:en",
])
->willReturnOnConsecutiveCalls(FALSE, (object) [
'data' => $expected_views_data,
], FALSE);
$this->cacheBackend
->expects($this->exactly(2))
->method('set')
->withConsecutive([
"views_data:{$table_name}:en",
$expected_views_data[$table_name],
], [
"views_data:{$table_name_2}:en",
$expected_views_data[$table_name_2],
]);
$this->assertSame($expected_views_data[$table_name], $this->viewsData
->get($table_name));
$this->assertSame($expected_views_data[$table_name_2], $this->viewsData
->get($table_name_2));
// Should only be invoked the first time.
$this->assertSame($expected_views_data[$table_name], $this->viewsData
->get($table_name));
$this->assertSame($expected_views_data[$table_name_2], $this->viewsData
->get($table_name_2));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.