CC-5651: Unit Test the Scheduler
This commit is contained in:
parent
c329d54252
commit
bdf5dc4982
1 changed files with 7 additions and 34 deletions
|
@ -12,75 +12,51 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
||||||
$this->_showService = new Application_Service_ShowService();
|
$this->_showService = new Application_Service_ShowService();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatShowDurationOneHour()
|
public function testFormatShowDuration()
|
||||||
{
|
{
|
||||||
$duration = Application_Service_ShowService::formatShowDuration("01h 00m");
|
$duration = Application_Service_ShowService::formatShowDuration("01h 00m");
|
||||||
$this->assertEquals("01:00", $duration);
|
$this->assertEquals("01:00", $duration);
|
||||||
}
|
|
||||||
|
|
||||||
public function testFormatShowDurationLessThanOneHour()
|
|
||||||
{
|
|
||||||
$duration = Application_Service_ShowService::formatShowDuration("00h 05m");
|
$duration = Application_Service_ShowService::formatShowDuration("00h 05m");
|
||||||
$this->assertEquals("00:05", $duration);
|
$this->assertEquals("00:05", $duration);
|
||||||
}
|
|
||||||
|
|
||||||
public function testFormatShowDurationMoreTHanOneHour()
|
|
||||||
{
|
|
||||||
$duration = Application_Service_ShowService::formatShowDuration("03h 55m");
|
$duration = Application_Service_ShowService::formatShowDuration("03h 55m");
|
||||||
$this->assertEquals("03:55", $duration);
|
$this->assertEquals("03:55", $duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCalculateEndDateNoRepeat()
|
public function testCalculateEndDate()
|
||||||
{
|
{
|
||||||
$end = $this->_showService->calculateEndDate(ShowServiceData::getNoRepeatNoRRData());
|
$end = $this->_showService->calculateEndDate(ShowServiceData::getNoRepeatNoRRData());
|
||||||
$this->assertEquals(null, $end);
|
$this->assertEquals(null, $end);
|
||||||
}
|
|
||||||
|
|
||||||
public function testCalculateEndDateRepeatWithEndDate()
|
|
||||||
{
|
|
||||||
$end = $this->_showService->calculateEndDate(ShowServiceData::getWeeklyRepeatWithEndNoRRData());
|
$end = $this->_showService->calculateEndDate(ShowServiceData::getWeeklyRepeatWithEndNoRRData());
|
||||||
$this->assertEquals(new DateTime("2016-01-27", new DateTimeZone("UTC")), $end);
|
$this->assertEquals(new DateTime("2016-01-27", new DateTimeZone("UTC")), $end);
|
||||||
}
|
|
||||||
|
|
||||||
public function testCalculateEndDateRepeatWithNoEndDate()
|
|
||||||
{
|
|
||||||
$end = $this->_showService->calculateEndDate(ShowServiceData::getWeeklyRepeatNoEndNoRRData());
|
$end = $this->_showService->calculateEndDate(ShowServiceData::getWeeklyRepeatNoEndNoRRData());
|
||||||
$this->assertEquals(null, $end);
|
$this->assertEquals(null, $end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetMonthlyWeeklyRepeatIntervalFirstWeek()
|
public function testGetMonthlyWeeklyRepeatInterval()
|
||||||
{
|
{
|
||||||
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
||||||
new DateTime("2016-01-01"), new DateTimeZone("UTC"));
|
new DateTime("2016-01-01"), new DateTimeZone("UTC"));
|
||||||
$this->assertEquals(array("first", "Friday"), $repeatInterval);
|
$this->assertEquals(array("first", "Friday"), $repeatInterval);
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMonthlyWeeklyRepeatIntervalSecondWeek()
|
|
||||||
{
|
|
||||||
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
||||||
new DateTime("2016-01-12"), new DateTimeZone("UTC"));
|
new DateTime("2016-01-12"), new DateTimeZone("UTC"));
|
||||||
$this->assertEquals(array("second", "Tuesday"), $repeatInterval);
|
$this->assertEquals(array("second", "Tuesday"), $repeatInterval);
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMonthlyWeeklyRepeatIntervalThirdWeek()
|
|
||||||
{
|
|
||||||
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
||||||
new DateTime("2016-01-18"), new DateTimeZone("UTC"));
|
new DateTime("2016-01-18"), new DateTimeZone("UTC"));
|
||||||
$this->assertEquals(array("third", "Monday"), $repeatInterval);
|
$this->assertEquals(array("third", "Monday"), $repeatInterval);
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMonthlyWeeklyRepeatIntervalFifthWeek()
|
|
||||||
{
|
|
||||||
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
|
||||||
new DateTime("2016-01-30"), new DateTimeZone("UTC"));
|
|
||||||
$this->assertEquals(array("fifth", "Saturday"), $repeatInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetMonthlyWeeklyRepeatIntervalFourthWeek()
|
|
||||||
{
|
|
||||||
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
||||||
new DateTime("2016-01-28"), new DateTimeZone("UTC"));
|
new DateTime("2016-01-28"), new DateTimeZone("UTC"));
|
||||||
$this->assertEquals(array("fourth", "Thursday"), $repeatInterval);
|
$this->assertEquals(array("fourth", "Thursday"), $repeatInterval);
|
||||||
|
|
||||||
|
$repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval(
|
||||||
|
new DateTime("2016-01-30"), new DateTimeZone("UTC"));
|
||||||
|
$this->assertEquals(array("fifth", "Saturday"), $repeatInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetNextMonthlyMonthlyRepeatDate()
|
public function testGetNextMonthlyMonthlyRepeatDate()
|
||||||
|
@ -88,10 +64,7 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
||||||
$next = $this->_showService->getNextMonthlyMonthlyRepeatDate(
|
$next = $this->_showService->getNextMonthlyMonthlyRepeatDate(
|
||||||
new DateTime("2016-01-01"), "UTC", "00:00");
|
new DateTime("2016-01-01"), "UTC", "00:00");
|
||||||
$this->assertEquals(new DateTime("2016-02-01", new DateTimeZone("UTC")), $next);
|
$this->assertEquals(new DateTime("2016-02-01", new DateTimeZone("UTC")), $next);
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetNextMonthlyMonthlyRepeatDateSkipsMonth()
|
|
||||||
{
|
|
||||||
$next = $this->_showService->getNextMonthlyMonthlyRepeatDate(
|
$next = $this->_showService->getNextMonthlyMonthlyRepeatDate(
|
||||||
new DateTime("2016-01-30"), "UTC", "00:00");
|
new DateTime("2016-01-30"), "UTC", "00:00");
|
||||||
$this->assertEquals(new DateTime("2016-03-30", new DateTimeZone("UTC")), $next);
|
$this->assertEquals(new DateTime("2016-03-30", new DateTimeZone("UTC")), $next);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue