function TranslationManagerTest::testTranslatePlaceholder

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

Tests translation using placeholders.

@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 80

Class

TranslationManagerTest
@coversDefaultClass \Drupal\Core\StringTranslation\TranslationManager @group StringTranslation

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.