getName() public method

The name of this holiday is returned translated in the given locale. If for the given locale no translation is defined, the name in the default locale ('en_US') is returned. In case there is no translation at all, the short internal name is returned.
public getName ( )
Beispiel #1
0
 /**
  * Tests the getName function of the Holiday object with global translations and an overriding custom translation.
  */
 public function testHolidayGetNameWithOverridenGlobalTranslations()
 {
     /** @var TranslationsInterface|PHPUnit_Framework_MockObject_MockObject $translationsStub */
     $translationsStub = $this->getMockBuilder('\\Yasumi\\TranslationsInterface')->getMock();
     $translations = ['en_US' => 'New Year\'s Day', 'pl_PL' => 'Nowy Rok'];
     $translationsStub->expects($this->once())->method('getTranslations')->with($this->equalTo('newYearsDay'))->willReturn($translations);
     $customLocale = 'pl_PL';
     $customTranslation = 'Bardzo Nowy Rok';
     $holiday = new Holiday('newYearsDay', [$customLocale => $customTranslation], new DateTime("2014-01-01"), $customLocale);
     $holiday->mergeGlobalTranslations($translationsStub);
     $this->assertNotNull($holiday->getName());
     $this->assertInternalType('string', $holiday->getName());
     $this->assertEquals($customTranslation, $holiday->getName());
 }