function ViewsHooksTest::testViewsInvalidateCacheOnDelete

Same name in other branches
  1. 10 core/modules/views/tests/src/Kernel/ViewsHooksTest.php \Drupal\Tests\views\Kernel\ViewsHooksTest::testViewsInvalidateCacheOnDelete()

Test that hook_views_invalidate_cache() is called when a view is deleted.

File

core/modules/views/tests/src/Kernel/ViewsHooksTest.php, line 134

Class

ViewsHooksTest
Tests that views hooks are registered when defined in $module.views.inc.

Namespace

Drupal\Tests\views\Kernel

Code

public function testViewsInvalidateCacheOnDelete() : void {
    $this->container
        ->get('state')
        ->set('views_hook_test_views_invalidate_cache', FALSE);
    $view = $this->viewStorage
        ->load('test_view');
    $view->delete();
    $this->assertTrue($this->container
        ->get('state')
        ->get('views_hook_test_views_invalidate_cache'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.