function TranslationManagerTest::testFormatPlural

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

@dataProvider providerTestFormatPlural

File

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

Class

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

Namespace

Drupal\Tests\Core\StringTranslation

Code

public function testFormatPlural($count, $singular, $plural, array $args, array $options, $expected) {
    $langcode = empty($options['langcode']) ? 'fr' : $options['langcode'];
    $translator = $this->createMock('\\Drupal\\Core\\StringTranslation\\Translator\\TranslatorInterface');
    $translator->expects($this->once())
        ->method('getStringTranslation')
        ->with($langcode, $this->anything(), $this->anything())
        ->willReturnCallback(function ($langcode, $string, $context) {
        return $string;
    });
    $this->translationManager
        ->setDefaultLangcode('fr');
    $this->translationManager
        ->addTranslator($translator);
    $result = $this->translationManager
        ->formatPlural($count, $singular, $plural, $args, $options);
    $this->assertEquals($expected, $result);
    $this->assertInstanceOf(MarkupInterface::class, $result);
}

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