diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php index 10803b0..5cf40cb 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php @@ -56,26 +56,19 @@ public function testViewsFetchData() { // Verify that views_test_data_views_data() has only been called once. $state = state(); - $this->assertEqual(2, $state->get('views_test_data_views_data_count')); + $count = $state->get('views_test_data_views_data_count'); - // Selectivly clear the views data cache. - $this->viewsDataCache->delete($table_name); - // Get the data again. - $this->viewsDataCache->get($table_name); - // Verify that view_test_data_views_data() has run again. - $this->assertEqual(3, $state->get('views_test_data_views_data_count')); - - // Same again, clearing the entire cache. + // Flush the storage/cache. $this->viewsDataCache->delete(); // Get the data again. $this->viewsDataCache->get($table_name); // Verify that view_test_data_views_data() has run again. - $this->assertEqual(4, $state->get('views_test_data_views_data_count')); + $this->assertEqual($count + 1, $state->get('views_test_data_views_data_count')); // Get the data again. $this->viewsDataCache->get($table_name); // Verify that view_test_data_views_data() has not run again. - $this->assertEqual(4, $state->get('views_test_data_views_data_count')); + $this->assertEqual($count + 1, $state->get('views_test_data_views_data_count')); } /** diff --git a/core/modules/views/lib/Drupal/views/ViewsDataCache.php b/core/modules/views/lib/Drupal/views/ViewsDataCache.php index 1a09252..e30e24b 100644 --- a/core/modules/views/lib/Drupal/views/ViewsDataCache.php +++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.php @@ -257,18 +257,10 @@ public function destruct() { } /** - * Allows an entry in the storage to be removed. - * @param string $key - * (Optional) The key to clear in the storage. Defaults to NULL. + * Allows a module to flush the storage and cache. */ - public function delete($key = NULL) { - if ($key) { - unset($this->storage[$key]); - $this->cacheBackend->delete($this->baseCid . ':' . $key); - } - else { - $this->storage = array(); - $this->cacheBackend->deleteAll(); - } + public function delete() { + $this->storage = array(); + $this->cacheBackend->deleteAll(); } } diff --git a/core/modules/views/tests/views_test_data/views_test_data.views.inc b/core/modules/views/tests/views_test_data/views_test_data.views.inc index 199401d..b1573e1 100644 --- a/core/modules/views/tests/views_test_data/views_test_data.views.inc +++ b/core/modules/views/tests/views_test_data/views_test_data.views.inc @@ -26,6 +26,9 @@ function views_test_data_views_analyze(ViewExecutable $view) { */ function views_test_data_views_data() { $state = state(); + // We use a state variable to keep track of how many times this function is + // called so we can assert that calls to + // \Drupal\views\ViewsDataCache::delete() trigger a rebuild of views data. if (!($count = $state->get('views_test_data_views_data_count'))) { $count = 0; }