function RendererTest::assertAccess
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::assertAccess()
- 10 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::assertAccess()
- 11.x core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::assertAccess()
Asserts that a render array with access checking renders correctly.
Parameters
array $build: A render array with either #access or #access_callback.
bool $access: Whether the render array is accessible or not.
4 calls to RendererTest::assertAccess()
- RendererTest::testRenderWithAccessCallbackCallable in core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php - @covers ::render @covers ::doRender
- RendererTest::testRenderWithAccessControllerResolved in core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php - @covers ::render @covers ::doRender
- RendererTest::testRenderWithAccessPropertyAndCallback in core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php - Ensures that the #access property wins over the callable.
- RendererTest::testRenderWithPresetAccess in core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php - @covers ::render @covers ::doRender
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php, line 722
Class
- RendererTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
protected function assertAccess($build, $access) {
$sensitive_content = $this->randomContextValue();
$build['#markup'] = $sensitive_content;
if ($access instanceof AccessResultInterface && $access->isAllowed() || $access === TRUE) {
$this->assertSame($sensitive_content, (string) $this->renderer
->renderRoot($build));
}
else {
$this->assertSame('', (string) $this->renderer
->renderRoot($build));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.