function ViewsDataTest::testCacheCallsWithWarmCacheAndDifferentTable
Same name in other branches
- 9 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithWarmCacheAndDifferentTable()
- 10 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithWarmCacheAndDifferentTable()
- 11.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testCacheCallsWithWarmCacheAndDifferentTable()
Tests the cache calls for a different table than the one in cache:
Warm cache:
- all tables
- views_test_data
Not warm cache:
- views_test_data_2
File
-
core/
modules/ views/ tests/ src/ Unit/ ViewsDataTest.php, line 456
Class
- ViewsDataTest
- @coversDefaultClass \Drupal\views\ViewsData @group views
Namespace
Drupal\Tests\views\UnitCode
public function testCacheCallsWithWarmCacheAndDifferentTable() {
$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->at(0))
->method('get')
->with('views_data:views_test_data_2:en');
$this->cacheBackend
->expects($this->at(1))
->method('get')
->with('views_data:en')
->will($this->returnValue((object) [
'data' => $expected_views_data,
]));
$this->cacheBackend
->expects($this->at(2))
->method('set')
->with('views_data:views_test_data_2:en', $expected_views_data['views_test_data_2']);
// Requests a different table as the cache contains. This will fail to get a
// table specific cache entry, load the cache entry for all tables and save
// a cache entry for this table but not all.
for ($i = 0; $i < 5; $i++) {
$views_data = $this->viewsData
->get('views_test_data_2');
$this->assertSame($expected_views_data['views_test_data_2'], $views_data);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.