Skip to content
Extraits de code Groupes Projets
Valider e5d93e56 rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

refs #3227 added tests for uncovered methods

git-svn-id: http://dev.piwik.org/svn/trunk@6511 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 38ceaeeb
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -212,4 +212,63 @@ class Period_DayTest extends PHPUnit_Framework_TestCase
// expected string
$this->assertEquals("2007-12-31", $endDate->toString());
}
/**
* adding a subperiod should not be possible
* @group Core
* @group Period
* @group Period_Day
*/
public function testAddSubperiodFails()
{
// create the period
$period = new Piwik_Period_Day( Piwik_Date::factory("2007-12-31"));
try {
$period->addSubperiod('');
} catch (Exception $e) {
return;
}
// expected string
$this->fail('Exception not raised');
}
/**
* @group Core
* @group Period
* @group Period_Day
*/
public function testGetLocalizedShortString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$month = new Piwik_Period_Day( Piwik_Date::factory('2024-10-09'));
$shouldBe = 'Wed 9 Oct';
$this->assertEquals($shouldBe, $month->getLocalizedShortString());
}
/**
* @group Core
* @group Period
* @group Period_Day
*/
public function testGetLocalizedLongString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$month = new Piwik_Period_Day( Piwik_Date::factory('2024-10-09'));
$shouldBe = 'Wednesday 9 October 2024';
$this->assertEquals($shouldBe, $month->getLocalizedLongString());
}
/**
* @group Core
* @group Period
* @group Period_Day
*/
public function testGetPrettyString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$month = new Piwik_Period_Day( Piwik_Date::factory('2024-10-09'));
$shouldBe = '2024-10-09';
$this->assertEquals($shouldBe, $month->getPrettyString());
}
}
\ No newline at end of file
......@@ -274,4 +274,43 @@ class Period_MonthTest extends PHPUnit_Framework_TestCase
$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());
}
}
\ No newline at end of file
......@@ -1027,7 +1027,7 @@ class Period_RangeTest extends PHPUnit_Framework_TestCase
* @group Period
* @group Period_Range
*/
public function test_InvalidRange_throws()
public function testInvalidRangeThrows()
{
try {
$range = new Piwik_Period_Range( 'range', '0001-01-01,today' );
......@@ -1037,4 +1037,43 @@ class Period_RangeTest extends PHPUnit_Framework_TestCase
}
$this->fail('Expected exception not raised');
}
/**
* @group Core
* @group Period
* @group Period_Range
*/
public function testGetLocalizedShortString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$month = new Piwik_Period_Range( 'range', '2000-12-09,2001-02-01' );
$shouldBe = '9 Dec 00 - 1 Feb 01';
$this->assertEquals($shouldBe, $month->getLocalizedShortString());
}
/**
* @group Core
* @group Period
* @group Period_Range
*/
public function testGetLocalizedLongString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$month = new Piwik_Period_Range( 'range', '2023-05-09,2023-05-21' );
$shouldBe = '8 May 23 - 21 May 23';
$this->assertEquals($shouldBe, $month->getLocalizedLongString());
}
/**
* @group Core
* @group Period
* @group Period_Range
*/
public function testGetPrettyString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$month = new Piwik_Period_Range( 'range', '2007-02-09,2007-03-15' );
$shouldBe = 'From 2007-02-09 to 2007-03-15';
$this->assertEquals($shouldBe, $month->getPrettyString());
}
}
\ No newline at end of file
......@@ -124,4 +124,43 @@ class Period_WeekTest extends PHPUnit_Framework_TestCase
$this->assertEquals($correct, $week->toString());
$this->assertEquals(7, $week->getNumberOfSubperiods());
}
/**
* @group Core
* @group Period
* @group Period_Week
*/
public function testGetLocalizedShortString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$week = new Piwik_Period_Week( Piwik_Date::factory('2024-10-09'));
$shouldBe = '7 Oct - 13 Oct 24';
$this->assertEquals($shouldBe, $week->getLocalizedShortString());
}
/**
* @group Core
* @group Period
* @group Period_Week
*/
public function testGetLocalizedLongString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$week = new Piwik_Period_Week( Piwik_Date::factory('2024-10-09'));
$shouldBe = 'Week 7 October - 13 October 2024';
$this->assertEquals($shouldBe, $week->getLocalizedLongString());
}
/**
* @group Core
* @group Period
* @group Period_Week
*/
public function testGetPrettyString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$week = new Piwik_Period_Week( Piwik_Date::factory('2024-10-09'));
$shouldBe = 'From 2024-10-07 to 2024-10-13';
$this->assertEquals($shouldBe, $week->getPrettyString());
}
}
......@@ -61,8 +61,47 @@ class Period_YearTest extends PHPUnit_Framework_TestCase
'2000-12-01',
);
$week = new Piwik_Period_Year( Piwik_Date::factory('2000-02-15'));
$this->assertEquals(12, $week->getNumberOfSubperiods());
$this->assertEquals($correct, $week->toString());
$year = new Piwik_Period_Year( Piwik_Date::factory('2000-02-15'));
$this->assertEquals(12, $year->getNumberOfSubperiods());
$this->assertEquals($correct, $year->toString());
}
/**
* @group Core
* @group Period
* @group Period_Year
*/
public function testGetLocalizedShortString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$year = new Piwik_Period_Year( Piwik_Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getLocalizedShortString());
}
/**
* @group Core
* @group Period
* @group Period_Year
*/
public function testGetLocalizedLongString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$year = new Piwik_Period_Year( Piwik_Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getLocalizedLongString());
}
/**
* @group Core
* @group Period
* @group Period_Year
*/
public function testGetPrettyString()
{
Piwik_Translate::getInstance()->loadEnglishTranslation();
$year = new Piwik_Period_Year( Piwik_Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getPrettyString());
}
}
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter