You are here

public function FormattableMarkupTest::providerTestUnexpectedPlaceholder in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::providerTestUnexpectedPlaceholder()
  2. 9 core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::providerTestUnexpectedPlaceholder()

Data provider for FormattableMarkupTest::testUnexpectedPlaceholder().

Return value

array

File

core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php, line 95

Class

FormattableMarkupTest
Tests the TranslatableMarkup class.

Namespace

Drupal\Tests\Component\Render

Code

public function providerTestUnexpectedPlaceholder() {
  return [
    [
      'Non alpha starting character: ~placeholder',
      [
        '~placeholder' => 'replaced',
      ],
      E_USER_WARNING,
      'Invalid placeholder (~placeholder) with string: "Non alpha starting character: ~placeholder"',
    ],
    [
      'Alpha starting character: placeholder',
      [
        'placeholder' => 'replaced',
      ],
      E_USER_WARNING,
      'Invalid placeholder (placeholder) with string: "Alpha starting character: placeholder"',
    ],
    // Ensure that where the placeholder is located in the string is
    // irrelevant.
    [
      'placeholder',
      [
        'placeholder' => 'replaced',
      ],
      E_USER_WARNING,
      'Invalid placeholder (placeholder) with string: "placeholder"',
    ],
    [
      'No replacements',
      [
        'foo' => 'bar',
      ],
      E_USER_WARNING,
      'Invalid placeholder (foo) with string: "No replacements"',
    ],
  ];
}