function ControllerBaseTest::testCreate
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Controller/ControllerBaseTest.php \Drupal\KernelTests\Core\Controller\ControllerBaseTest::testCreate()
@covers ::create
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Controller/ ControllerBaseTest.php, line 28
Class
Namespace
Drupal\KernelTests\Core\ControllerCode
public function testCreate() : void {
/** @var \Drupal\system_test\Controller\SystemTestController $controller */
$controller = $this->container
->get('class_resolver')
->getInstanceFromDefinition(SystemTestController::class);
$property = new \ReflectionProperty(SystemTestController::class, 'lock');
$this->assertSame($this->container
->get('lock'), $property->getValue($controller));
$property = new \ReflectionProperty(SystemTestController::class, 'persistentLock');
$this->assertSame($this->container
->get('lock.persistent'), $property->getValue($controller));
$property = new \ReflectionProperty(SystemTestController::class, 'currentUser');
$this->assertSame($this->container
->get('current_user'), $property->getValue($controller));
// Test nullables types.
$this->assertSame($this->container
->get('page_cache_kill_switch'), $controller->killSwitch);
$this->assertSame($this->container
->get('page_cache_kill_switch'), $controller->killSwitch2);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.