/** * @dataProvider providerTestFormatPlural */ public function testFormatPlural($count, $singular, $plural, array $args = array(), array $options = array(), $expected) { $translator = $this->getMock('\\Drupal\\Core\\StringTranslation\\Translator\\TranslatorInterface'); $translator->expects($this->once())->method('getStringTranslation')->will($this->returnCallback(function ($langcode, $string) { return $string; })); $this->translationManager->addTranslator($translator); $result = $this->translationManager->formatPlural($count, $singular, $plural, $args, $options); $this->assertEquals($expected, $result); }
/** * @dataProvider providerTestFormatPlural */ 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->assertInstanceOf(MarkupInterface::class, $result); }