function ChainedPlaceholderStrategyTest::testProcessPlaceholdersWithRoguePlaceholderStrategy

Same name 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. 11.x 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 \Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy @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.