function TranslationManagerTest::testTranslatePlaceholder

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php \Drupal\Tests\Core\StringTranslation\TranslationManagerTest::testTranslatePlaceholder()
  2. 9 core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php \Drupal\Tests\Core\StringTranslation\TranslationManagerTest::testTranslatePlaceholder()
  3. 8.9.x core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php \Drupal\Tests\Core\StringTranslation\TranslationManagerTest::testTranslatePlaceholder()

Tests translation using placeholders.

Attributes

#[DataProvider('providerTestTranslatePlaceholder')]

Parameters

string $string: A string containing the English text to translate.

array $args: An associative array of replacements to make after translation.

string $expected_string: The expected translated string value.

File

core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php, line 85

Class

TranslationManagerTest
Tests Drupal\Core\StringTranslation\TranslationManager.

Namespace

Drupal\Tests\Core\StringTranslation

Code

public function testTranslatePlaceholder($string, array $args, $expected_string) : void {
  $actual = $this->translationManager
    ->translate($string, $args);
  $this->assertInstanceOf(MarkupInterface::class, $actual);
  $this->assertEquals($expected_string, (string) $actual);
}

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