function 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 802  
Class
- RendererPlaceholdersTest
 - @coversDefaultClass \Drupal\Core\Render\Renderer[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache[[api-linebreak]] @covers \Drupal\Core\Render\PlaceholderingRenderCache[[api-linebreak]] @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.');
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.