assertEquals($correct, $month->toString()); $this->assertEquals(31, $month->getNumberOfSubperiods()); } /** * testing month feb leap year * @group Core * @group Period * @group Period_Month */ public function testMonthFebLeap() { $month = new Piwik_Period_Month(Piwik_Date::factory("2024-02-11")); $correct = array( "2024-02-01", "2024-02-02", "2024-02-03", "2024-02-04", "2024-02-05", "2024-02-06", "2024-02-07", "2024-02-08", "2024-02-09", "2024-02-10", "2024-02-11", "2024-02-12", "2024-02-13", "2024-02-14", "2024-02-15", "2024-02-16", "2024-02-17", "2024-02-18", "2024-02-19", "2024-02-20", "2024-02-21", "2024-02-22", "2024-02-23", "2024-02-24", "2024-02-25", "2024-02-26", "2024-02-27", "2024-02-28", "2024-02-29",); $this->assertEquals($correct, $month->toString()); $this->assertEquals(29, $month->getNumberOfSubperiods()); } /** * testing month feb non-leap year * @group Core * @group Period * @group Period_Month */ public function testMonthFebNonLeap() { $month = new Piwik_Period_Month(Piwik_Date::factory("2023-02-11")); $correct = array( "2023-02-01", "2023-02-02", "2023-02-03", "2023-02-04", "2023-02-05", "2023-02-06", "2023-02-07", "2023-02-08", "2023-02-09", "2023-02-10", "2023-02-11", "2023-02-12", "2023-02-13", "2023-02-14", "2023-02-15", "2023-02-16", "2023-02-17", "2023-02-18", "2023-02-19", "2023-02-20", "2023-02-21", "2023-02-22", "2023-02-23", "2023-02-24", "2023-02-25", "2023-02-26", "2023-02-27", "2023-02-28",); $this->assertEquals($correct, $month->toString()); $this->assertEquals(28, $month->getNumberOfSubperiods()); } /** * testing jan * @group Core * @group Period * @group Period_Month */ public function testMonthJan() { $month = new Piwik_Period_Month(Piwik_Date::factory("2007-01-01")); $correct = array( "2007-01-01", "2007-01-02", "2007-01-03", "2007-01-04", "2007-01-05", "2007-01-06", "2007-01-07", "2007-01-08", "2007-01-09", "2007-01-10", "2007-01-11", "2007-01-12", "2007-01-13", "2007-01-14", "2007-01-15", "2007-01-16", "2007-01-17", "2007-01-18", "2007-01-19", "2007-01-20", "2007-01-21", "2007-01-22", "2007-01-23", "2007-01-24", "2007-01-25", "2007-01-26", "2007-01-27", "2007-01-28", "2007-01-29", "2007-01-30", "2007-01-31",); $this->assertEquals($correct, $month->toString()); $this->assertEquals(31, $month->getNumberOfSubperiods()); } /** * testing month containing a time change (DST) * @group Core * @group Period * @group Period_Month */ public function testMonthDSTChangeMarch() { $month = new Piwik_Period_Month(Piwik_Date::factory("2007-02-31")); $correct = array( "2007-03-01", "2007-03-02", "2007-03-03", "2007-03-04", "2007-03-05", "2007-03-06", "2007-03-07", "2007-03-08", "2007-03-09", "2007-03-10", "2007-03-11", "2007-03-12", "2007-03-13", "2007-03-14", "2007-03-15", "2007-03-16", "2007-03-17", "2007-03-18", "2007-03-19", "2007-03-20", "2007-03-21", "2007-03-22", "2007-03-23", "2007-03-24", "2007-03-25", "2007-03-26", "2007-03-27", "2007-03-28", "2007-03-29", "2007-03-30", "2007-03-31",); $this->assertEquals($correct, $month->toString()); $this->assertEquals(31, $month->getNumberOfSubperiods()); } /** * @group Core * @group Period * @group Period_Month */ public function testMonthDSTChangeOct() { $month = new Piwik_Period_Month(Piwik_Date::factory("2017-10-31")); $correct = array( "2017-10-01", "2017-10-02", "2017-10-03", "2017-10-04", "2017-10-05", "2017-10-06", "2017-10-07", "2017-10-08", "2017-10-09", "2017-10-10", "2017-10-11", "2017-10-12", "2017-10-13", "2017-10-14", "2017-10-15", "2017-10-16", "2017-10-17", "2017-10-18", "2017-10-19", "2017-10-20", "2017-10-21", "2017-10-22", "2017-10-23", "2017-10-24", "2017-10-25", "2017-10-26", "2017-10-27", "2017-10-28", "2017-10-29", "2017-10-30", "2017-10-31",); $this->assertEquals($correct, $month->toString()); $this->assertEquals(31, $month->getNumberOfSubperiods()); } /** * @group Core * @group Period * @group Period_Month */ public function testGetLocalizedShortString() { Piwik_Translate::getInstance()->loadEnglishTranslation(); $month = new Piwik_Period_Month(Piwik_Date::factory('2024-10-09')); $shouldBe = 'Oct 2024'; $this->assertEquals($shouldBe, $month->getLocalizedShortString()); } /** * @group Core * @group Period * @group Period_Month */ public function testGetLocalizedLongString() { Piwik_Translate::getInstance()->loadEnglishTranslation(); $month = new Piwik_Period_Month(Piwik_Date::factory('2024-10-09')); $shouldBe = '2024, October'; $this->assertEquals($shouldBe, $month->getLocalizedLongString()); } /** * @group Core * @group Period * @group Period_Month */ public function testGetPrettyString() { Piwik_Translate::getInstance()->loadEnglishTranslation(); $month = new Piwik_Period_Month(Piwik_Date::factory('2024-10-09')); $shouldBe = '2024-10'; $this->assertEquals($shouldBe, $month->getPrettyString()); } }