You are here

public function TranslationManagerTest::testFormatPlural in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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
Contains \Drupal\Tests\Core\StringTranslation\TranslationManagerTest.

Class

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

Namespace

Drupal\Tests\Core\StringTranslation

Code

public function testFormatPlural($count, $singular, $plural, array $args = array(), array $options = array(), $expected) {
  $langcode = empty($options['langcode']) ? 'fr' : $options['langcode'];
  $translator = $this
    ->getMock('\\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
    ->assertTrue(SafeMarkup::isSafe($result));
}