public function TranslationManagerTest::testFormatPlural in Drupal 8
Same name and namespace in other branches
- 9 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 - Contains \Drupal\Tests\Core\StringTranslation\TranslationManagerTest.
Class
- TranslationManagerTest
- @coversDefaultClass \Drupal\Core\StringTranslation\TranslationManager @group StringTranslation
Namespace
Drupal\Tests\Core\StringTranslationCode
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())
->will($this
->returnCallback(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);
}