diff --git a/airtime_mvc/tests/application/bootstrap.php b/airtime_mvc/tests/application/bootstrap.php index 12fe35bac..66f008f1b 100644 --- a/airtime_mvc/tests/application/bootstrap.php +++ b/airtime_mvc/tests/application/bootstrap.php @@ -40,6 +40,9 @@ set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_pat //Services set_include_path(APPLICATION_PATH . '/services' . PATH_SEPARATOR . get_include_path()); +//models +set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); + //Controller plugins. set_include_path(APPLICATION_PATH . '/controllers/plugins' . PATH_SEPARATOR . get_include_path()); diff --git a/airtime_mvc/tests/application/services/ShowServiceTest.php b/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php similarity index 99% rename from airtime_mvc/tests/application/services/ShowServiceTest.php rename to airtime_mvc/tests/application/services/database/ShowServiceDbTest.php index 883a4820d..eec41a8dd 100644 --- a/airtime_mvc/tests/application/services/ShowServiceTest.php +++ b/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php @@ -6,7 +6,7 @@ require_once "AirtimeInstall.php"; require_once "ShowServiceData.php"; require_once "TestHelper.php"; -class ShowServiceTest extends Zend_Test_PHPUnit_DatabaseTestCase +class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase { private $_connectionMock; diff --git a/airtime_mvc/tests/application/services/datasets/cc_show_seed.xml b/airtime_mvc/tests/application/services/database/datasets/cc_show_seed.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/cc_show_seed.xml rename to airtime_mvc/tests/application/services/database/datasets/cc_show_seed.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_ccShowInsertedIntoDatabase.xml b/airtime_mvc/tests/application/services/database/datasets/test_ccShowInsertedIntoDatabase.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_ccShowInsertedIntoDatabase.xml rename to airtime_mvc/tests/application/services/database/datasets/test_ccShowInsertedIntoDatabase.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_deleteRepeatingShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_deleteRepeatingShow.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_deleteRepeatingShow.xml rename to airtime_mvc/tests/application/services/database/datasets/test_deleteRepeatingShow.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_deleteShowInstance.xml b/airtime_mvc/tests/application/services/database/datasets/test_deleteShowInstance.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_deleteShowInstance.xml rename to airtime_mvc/tests/application/services/database/datasets/test_deleteShowInstance.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_deleteShowInstanceAndAllFollowing.xml b/airtime_mvc/tests/application/services/database/datasets/test_deleteShowInstanceAndAllFollowing.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_deleteShowInstanceAndAllFollowing.xml rename to airtime_mvc/tests/application/services/database/datasets/test_deleteShowInstanceAndAllFollowing.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_editRepeatingShowInstance.xml b/airtime_mvc/tests/application/services/database/datasets/test_editRepeatingShowInstance.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_editRepeatingShowInstance.xml rename to airtime_mvc/tests/application/services/database/datasets/test_editRepeatingShowInstance.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_noRepeatNoRRShowCreated.xml b/airtime_mvc/tests/application/services/database/datasets/test_noRepeatNoRRShowCreated.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_noRepeatNoRRShowCreated.xml rename to airtime_mvc/tests/application/services/database/datasets/test_noRepeatNoRRShowCreated.xml diff --git a/airtime_mvc/tests/application/services/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml b/airtime_mvc/tests/application/services/database/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml similarity index 100% rename from airtime_mvc/tests/application/services/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml rename to airtime_mvc/tests/application/services/database/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml diff --git a/airtime_mvc/tests/application/services/testdata/ShowServiceData.php b/airtime_mvc/tests/application/services/testdata/ShowServiceData.php index c46f97fe8..1bcebd28f 100644 --- a/airtime_mvc/tests/application/services/testdata/ShowServiceData.php +++ b/airtime_mvc/tests/application/services/testdata/ShowServiceData.php @@ -151,6 +151,81 @@ Class ShowServiceData ); } + public static function getWeeklyRepeatWithEndNoRRData() + { + return array( + "add_show_id" => -1, + "add_show_instance_id" => -1, + "add_show_name" => "test show", + "add_show_url" => null, + "add_show_genre" => null, + "add_show_description" => null, + "add_show_start_date" => "2016-01-01", + "add_show_start_time" => "00:00", + "add_show_end_date_no_repeat" => "2016-01-01", + "add_show_end_time" => "01:00", + "add_show_duration" => "01h 00m", + "add_show_timezone" => "UTC", + "add_show_repeats" => 1, + "add_show_linked" => 0, + "add_show_repeat_type" => 0, + "add_show_monthly_repeat_type" => 2, + "add_show_end_date" => "2016-01-26", + "add_show_no_end" => 0, + "cb_airtime_auth" => 0, + "cb_custom_auth" => 0, + "custom_username" => null, + "custom_password" => null, + "add_show_record" => 0, + "add_show_rebroadcast" => 0, + "add_show_rebroadcast_date_absolute_1" => null, + "add_show_rebroadcast_time_absolute_1" => null, + "add_show_rebroadcast_date_absolute_2" => null, + "add_show_rebroadcast_time_absolute_2" => null, + "add_show_rebroadcast_date_absolute_3" => null, + "add_show_rebroadcast_time_absolute_3" => null, + "add_show_rebroadcast_date_absolute_4" => null, + "add_show_rebroadcast_time_absolute_4" => null, + "add_show_rebroadcast_date_absolute_5" => null, + "add_show_rebroadcast_time_absolute_5" => null, + "add_show_rebroadcast_date_absolute_6" => null, + "add_show_rebroadcast_time_absolute_6" => null, + "add_show_rebroadcast_date_absolute_7" => null, + "add_show_rebroadcast_time_absolute_7" => null, + "add_show_rebroadcast_date_absolute_8" => null, + "add_show_rebroadcast_time_absolute_8" => null, + "add_show_rebroadcast_date_absolute_9" => null, + "add_show_rebroadcast_time_absolute_9" => null, + "add_show_rebroadcast_date_absolute_10" => null, + "add_show_rebroadcast_time_absolute_10" => null, + "add_show_rebroadcast_date_1" => null, + "add_show_rebroadcast_time_1" => null, + "add_show_rebroadcast_date_2" => null, + "add_show_rebroadcast_time_2" => null, + "add_show_rebroadcast_date_3" => null, + "add_show_rebroadcast_time_3" => null, + "add_show_rebroadcast_date_4" => null, + "add_show_rebroadcast_time_4" => null, + "add_show_rebroadcast_date_5" => null, + "add_show_rebroadcast_time_5" => null, + "add_show_rebroadcast_date_6" => null, + "add_show_rebroadcast_time_6" => null, + "add_show_rebroadcast_date_7" => null, + "add_show_rebroadcast_time_7" => null, + "add_show_rebroadcast_date_8" => null, + "add_show_rebroadcast_time_8" => null, + "add_show_rebroadcast_date_9" => null, + "add_show_rebroadcast_time_9" => null, + "add_show_rebroadcast_date_10" => null, + "add_show_rebroadcast_time_10" => null, + "add_show_hosts_autocomplete" => null, + "add_show_background_color" => "364492", + "add_show_color" => "ffffff", + "add_show_hosts" => null, + "add_show_day_check" => array(5) + ); + } + public static function getWeeklyRepeatDays() { return array(1,2,3,4,5); diff --git a/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php b/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php new file mode 100644 index 000000000..9c7565fc6 --- /dev/null +++ b/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php @@ -0,0 +1,104 @@ +_showService = new Application_Service_ShowService(); + } + + public function testFormatShowDurationOneHour() + { + $duration = Application_Service_ShowService::formatShowDuration("01h 00m"); + $this->assertEquals("01:00", $duration); + } + + public function testFormatShowDurationLessThanOneHour() + { + $duration = Application_Service_ShowService::formatShowDuration("00h 05m"); + $this->assertEquals("00:05", $duration); + } + + public function testFormatShowDurationMoreTHanOneHour() + { + $duration = Application_Service_ShowService::formatShowDuration("03h 55m"); + $this->assertEquals("03:55", $duration); + } + + public function testCalculateEndDateNoRepeat() + { + $end = $this->_showService->calculateEndDate(ShowServiceData::getNoRepeatNoRRData()); + $this->assertEquals(null, $end); + } + + public function testCalculateEndDateRepeatWithEndDate() + { + $end = $this->_showService->calculateEndDate(ShowServiceData::getWeeklyRepeatWithEndNoRRData()); + $this->assertEquals(new DateTime("2016-01-27", new DateTimeZone("UTC")), $end); + } + + public function testCalculateEndDateRepeatWithNoEndDate() + { + $end = $this->_showService->calculateEndDate(ShowServiceData::getWeeklyRepeatNoEndNoRRData()); + $this->assertEquals(null, $end); + } + + public function testGetMonthlyWeeklyRepeatIntervalFirstWeek() + { + $repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval( + new DateTime("2016-01-01"), new DateTimeZone("UTC")); + $this->assertEquals(array("first", "Friday"), $repeatInterval); + } + + public function testGetMonthlyWeeklyRepeatIntervalSecondWeek() + { + $repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval( + new DateTime("2016-01-12"), new DateTimeZone("UTC")); + $this->assertEquals(array("second", "Tuesday"), $repeatInterval); + } + + public function testGetMonthlyWeeklyRepeatIntervalThirdWeek() + { + $repeatInterval = $this->_showService->getMonthlyWeeklyRepeatInterval( + new DateTime("2016-01-18"), new DateTimeZone("UTC")); + $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( + new DateTime("2016-01-28"), new DateTimeZone("UTC")); + $this->assertEquals(array("fourth", "Thursday"), $repeatInterval); + } + + public function testGetNextMonthlyMonthlyRepeatDate() + { + $next = $this->_showService->getNextMonthlyMonthlyRepeatDate( + new DateTime("2016-01-01"), "UTC", "00:00"); + $this->assertEquals(new DateTime("2016-02-01", new DateTimeZone("UTC")), $next); + } + + public function testGetNextMonthlyMonthlyRepeatDateSkipsMonth() + { + $next = $this->_showService->getNextMonthlyMonthlyRepeatDate( + new DateTime("2016-01-30"), "UTC", "00:00"); + $this->assertEquals(new DateTime("2016-03-30", new DateTimeZone("UTC")), $next); + } + + public function testCreateUTCStartEndDateTime() + { + + } +} \ No newline at end of file