/** * 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()); }
/** * Adds a holiday to the holidays providers (i.e. country/state) list of holidays. * * @param Holiday $holiday Holiday instance (representing a holiday) to be added to the internal list * of holidays of this country. */ public function addHoliday(Holiday $holiday) { if ($this->globalTranslations !== null) { $holiday->mergeGlobalTranslations($this->globalTranslations); } $this->holidays[$holiday->shortName] = $holiday; uasort($this->holidays, ['Yasumi\\Provider\\AbstractProvider', 'compareDates']); }