Newer
Older
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
use Piwik\Period\Day;
use Piwik\Period\Week;
class PeriodTest extends \PHPUnit_Framework_TestCase
{
/**
* @group Core
*/
public function testGetId()
{
$period = new Day(Date::today());
$this->assertNotEquals(0, $period->getId());
$period = new Week(Date::today());
$this->assertNotEquals(0, $period->getId());
$period = new Month(Date::today());
$this->assertNotEquals(0, $period->getId());
$period = new Year(Date::today());
$this->assertNotEquals(0, $period->getId());
/**
* @group Core
*/
public function testGetLabel()
{
$period = new Day(Date::today());
$this->assertInternalType('string', $label);
$period = new Week(Date::today());
$this->assertInternalType('string', $label);
$period = new Month(Date::today());
$this->assertInternalType('string', $label);
$period = new Year(Date::today());
$this->assertInternalType('string', $label);
/**
* @group Core
*/
public function testFactoryDay()
{
mattab
a validé
$period = Period\Factory::build('day', Date::today());
$this->assertInstanceOf('\Piwik\Period\Day', $period);
}
/**
* @group Core
*/
public function testFactoryMonth()
{
mattab
a validé
$period = Period\Factory::build('month', Date::today());
$this->assertInstanceOf('\Piwik\Period\Month', $period);
}
/**
* @group Core
*/
public function testFactoryWeek()
{
mattab
a validé
$period = Period\Factory::build('week', Date::today());
$this->assertInstanceOf('\Piwik\Period\Week', $period);
}
/**
* @group Core
*/
public function testFactoryYear()
{
mattab
a validé
$period = Period\Factory::build('year', Date::today());
$this->assertInstanceOf('\Piwik\Period\Year', $period);
}
/**
* @group Core
*/
public function testFactoryInvalid()
{
try {
Period\Factory::build('inValid', Date::today());
return;
}
$this->fail('Expected Exception not raised');
}