CC-5651: Unit Test the Scheduler

This commit is contained in:
drigato 2014-01-16 17:16:29 -05:00
parent c329d54252
commit bdf5dc4982

View file

@ -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);