function TranslationManagerTest::testFormatPlural

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php \Drupal\Tests\Core\StringTranslation\TranslationManagerTest::testFormatPlural()
  2. 8.9.x core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php \Drupal\Tests\Core\StringTranslation\TranslationManagerTest::testFormatPlural()
  3. 10 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 54

Class

TranslationManagerTest
@coversDefaultClass \Drupal\Core\StringTranslation\TranslationManager[[api-linebreak]] @group StringTranslation

Namespace

Drupal\Tests\Core\StringTranslation

Code

public function testFormatPlural($count, $singular, $plural, array $args, array $options, $expected) : void {
  $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.