function ViewExecutableTest::assertViewDestroy

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::assertViewDestroy()
  2. 8.9.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::assertViewDestroy()
  3. 11.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::assertViewDestroy()

Asserts that expected view properties have been unset by destroy().

@internal

Parameters

\Drupal\views\ViewExecutable $view: The view executable.

1 call to ViewExecutableTest::assertViewDestroy()
ViewExecutableTest::testDestroy in core/modules/views/tests/src/Kernel/ViewExecutableTest.php
Tests the destructor to be sure that necessary objects are removed.

File

core/modules/views/tests/src/Kernel/ViewExecutableTest.php, line 376

Class

ViewExecutableTest
Tests the ViewExecutable class.

Namespace

Drupal\Tests\views\Kernel

Code

protected function assertViewDestroy(ViewExecutable $view) : void {
    $reflection = new \ReflectionClass($view);
    $defaults = $reflection->getDefaultProperties();
    // The storage and user should remain.
    unset($defaults['storage'], $defaults['user'], $defaults['request'], $defaults['routeProvider'], $defaults['displayPluginManager'], $defaults['viewsData']);
    foreach ($defaults as $property => $default) {
        $this->assertSame($this->getProtectedProperty($view, $property), $default);
    }
}

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