public function RendererPlaceholdersTest::testPlaceholderingDisabledForPostRequests in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testPlaceholderingDisabledForPostRequests()
@covers ::render @covers ::doRender @covers \Drupal\Core\Render\RenderCache::get @covers \Drupal\Core\Render\PlaceholderingRenderCache::get @covers \Drupal\Core\Render\PlaceholderingRenderCache::set @covers ::replacePlaceholders
@dataProvider providerPlaceholders
File
- core/tests/ Drupal/ Tests/ Core/ Render/ RendererPlaceholdersTest.php, line 799 
- Contains \Drupal\Tests\Core\Render\RendererPlaceholdersTest.
Class
- RendererPlaceholdersTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @covers \Drupal\Core\Render\RenderCache @covers \Drupal\Core\Render\PlaceholderingRenderCache @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testPlaceholderingDisabledForPostRequests($test_element, $args) {
  $this
    ->setUpUnusedCache();
  $this
    ->setUpRequest('POST');
  $element = $test_element;
  // Render without replacing placeholders, to allow this test to see which
  // #attached[placeholders] there are, if any.
  $this->renderer
    ->executeInRenderContext(new RenderContext(), function () use (&$element) {
    return $this->renderer
      ->render($element);
  });
  // Only test cases where the placeholders have been specified manually are
  // allowed to have placeholders. This means that of the different situations
  // listed in providerPlaceholders(), only type B can have attached
  // placeholders. Everything else, whether:
  // 1. manual placeholdering
  // 2. automatic placeholdering via already-present cacheability metadata
  // 3. automatic placeholdering via bubbled cacheability metadata
  // All three of those should NOT result in placeholders.
  if (!isset($test_element['#attached']['placeholders'])) {
    $this
      ->assertFalse(isset($element['#attached']['placeholders']), 'No placeholders created.');
  }
}