function RendererTest::assertAccess
Asserts that a render array with access checking renders correctly.
@internal
Parameters
array $build: A render array with either #access or #access_callback.
\Drupal\Core\Access\AccessResultInterface|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[[api-linebreak]] @covers ::doRender[[api-linebreak]]
- RendererTest::testRenderWithAccessControllerResolved in core/tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php 
- @covers ::render[[api-linebreak]] @covers ::doRender[[api-linebreak]]
- 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[[api-linebreak]] @covers ::doRender[[api-linebreak]]
File
- 
              core/tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php, line 742 
Class
- RendererTest
- @coversDefaultClass \Drupal\Core\Render\Renderer[[api-linebreak]] @group Render
Namespace
Drupal\Tests\Core\RenderCode
protected function assertAccess(array $build, $access) : void {
  $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.
