function ChainedPlaceholderStrategyTest::testProcessPlaceholdersWithRoguePlaceholderStrategy

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php \Drupal\Tests\Core\Render\Placeholder\ChainedPlaceholderStrategyTest::testProcessPlaceholdersWithRoguePlaceholderStrategy()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php \Drupal\Tests\Core\Render\Placeholder\ChainedPlaceholderStrategyTest::testProcessPlaceholdersWithRoguePlaceholderStrategy()
  3. 10 core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php \Drupal\Tests\Core\Render\Placeholder\ChainedPlaceholderStrategyTest::testProcessPlaceholdersWithRoguePlaceholderStrategy()

@covers ::processPlaceholders

File

core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php, line 143

Class

ChainedPlaceholderStrategyTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Render%21Placeholder%21ChainedPlaceholderStrategy.php/class/ChainedPlaceholderStrategy/11.x" title="Renders placeholders using a chain of placeholder strategies." class="local">\Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy</a> @group Render

Namespace

Drupal\Tests\Core\Render\Placeholder

Code

public function testProcessPlaceholdersWithRoguePlaceholderStrategy() : void {
    // Placeholders but no strategies defined.
    $placeholders = [
        'assert-me' => [
            '#markup' => 'llama',
        ],
    ];
    $result = [
        'assert-me' => [
            '#markup' => 'llama',
        ],
        'new-placeholder' => [
            '#markup' => 'rogue llama',
        ],
    ];
    $prophecy = $this->prophesize('\\Drupal\\Core\\Render\\Placeholder\\PlaceholderStrategyInterface');
    $prophecy->processPlaceholders($placeholders)
        ->willReturn($result);
    $rogue_strategy = $prophecy->reveal();
    $chained_placeholder_strategy = new ChainedPlaceholderStrategy();
    $chained_placeholder_strategy->addPlaceholderStrategy($rogue_strategy);
    $this->expectException(\AssertionError::class);
    $this->expectExceptionMessage('Processed placeholders must be a subset of all placeholders.');
    $chained_placeholder_strategy->processPlaceholders($placeholders);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.