コード例 #1
0
ファイル: TranslatorTest.php プロジェクト: nxpthx/FLOW3
 /**
  * @test
  */
 public function quantityIsDeterminedAutomaticallyIfOneNumricArgumentIsGivenToTranslateById()
 {
     $mockTranslationProvider = $this->getAccessibleMock('TYPO3\\FLOW3\\I18n\\TranslationProvider\\XliffTranslationProvider');
     $mockTranslationProvider->expects($this->once())->method('getTranslationById')->with('id', $this->defaultLocale, \TYPO3\FLOW3\I18n\Cldr\Reader\PluralsReader::RULE_ONE, 'source', 'packageKey')->will($this->returnValue('Translated label'));
     $mockFormatResolver = $this->getMock('TYPO3\\FLOW3\\I18n\\FormatResolver');
     $mockFormatResolver->expects($this->once())->method('resolvePlaceholders')->with('Translated label', array(1.0), $this->defaultLocale)->will($this->returnValue('Formatted and translated label'));
     $mockPluralsReader = $this->getMock('TYPO3\\FLOW3\\I18n\\Cldr\\Reader\\PluralsReader');
     $mockPluralsReader->expects($this->once())->method('getPluralForm')->with(1.0, $this->defaultLocale)->will($this->returnValue(\TYPO3\FLOW3\I18n\Cldr\Reader\PluralsReader::RULE_ONE));
     $this->translator->injectTranslationProvider($mockTranslationProvider);
     $this->translator->injectFormatResolver($mockFormatResolver);
     $this->translator->injectPluralsReader($mockPluralsReader);
     $result = $this->translator->translateById('id', array(1.0), NULL, NULL, 'source', 'packageKey');
     $this->assertEquals('Formatted and translated label', $result);
 }
コード例 #2
0
ファイル: TranslatorTest.php プロジェクト: nxpthx/FLOW3
 /**
  * @test
  * @dataProvider labelAndLocaleForTranslation
  */
 public function simpleTranslationByLabelWorks($label, $locale, $translation)
 {
     $result = $this->translator->translateByOriginalLabel($label, array(), NULL, $locale, 'Main', 'TYPO3.FLOW3');
     $this->assertEquals($translation, $result);
 }