From 0b4ae6b94dbb10a215a64267a633cfb28be3868c Mon Sep 17 00:00:00 2001 From: drigato Date: Tue, 14 Jan 2014 14:16:37 -0500 Subject: [PATCH] CC-5651: Unit Test the Scheduler Added test for deleting repeating show instances --- .../application/services/ShowService.php | 1 - .../tests/application/models/ShowTest.php | 34 ++ .../application/models/files/cc_show_seed.xml | 2 +- .../models/files/test_deleteShowInstance.xml | 15 +- ...test_deleteShowInstanceAndAllFollowing.xml | 314 ++++++++++++++++++ .../test_weeklyRepeatNoEndNoRRShowCreated.xml | 15 +- .../tests/application/testdata/ShowData.php | 5 + 7 files changed, 382 insertions(+), 4 deletions(-) create mode 100644 airtime_mvc/tests/application/models/files/test_deleteShowInstanceAndAllFollowing.xml diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index cb2305966..f1197c032 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -1408,7 +1408,6 @@ SQL; */ public function setCcShow($showData) { - Logging::info($showData); if (!$this->isUpdate) { $ccShow = new CcShow(); } else { diff --git a/airtime_mvc/tests/application/models/ShowTest.php b/airtime_mvc/tests/application/models/ShowTest.php index 2a5cb071e..f285aeec2 100644 --- a/airtime_mvc/tests/application/models/ShowTest.php +++ b/airtime_mvc/tests/application/models/ShowTest.php @@ -185,4 +185,38 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase $ds ); } + + /* Tests that when a user selects 'Delete this instance and all following + * on the calendar the database gets updated correctly + */ + public function testDeleteShowInstanceAndAllFollowing() + { + TestHelper::loginUser(); + + $data = ShowData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_day_check"] = array(5,1,2); + + $service_show = new Application_Service_ShowService(null, $data); + $service_show->addUpdateShow($data); + //delete some single instances first + $service_show->deleteShow(1, true); + $service_show->deleteShow(6, true); + $service_show->deleteShow(8, true); + //delete all instances including and after where id=4 + $service_show->deleteShow(4); + + $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( + $this->getConnection() + ); + $ds->addTable('cc_show', 'select * from cc_show'); + $ds->addTable('cc_show_days', 'select * from cc_show_days order by first_show'); + $ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, file_id, time_filled, last_scheduled, modified_instance from cc_show_instances order by id'); + $ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast'); + $ds->addTable('cc_show_hosts', 'select * from cc_show_hosts'); + + $this->assertDataSetsEqual( + $this->createXmlDataSet(dirname(__FILE__)."/files/test_deleteShowInstanceAndAllFollowing.xml"), + $ds + ); + } } diff --git a/airtime_mvc/tests/application/models/files/cc_show_seed.xml b/airtime_mvc/tests/application/models/files/cc_show_seed.xml index ced616de7..5dc86ce14 100644 --- a/airtime_mvc/tests/application/models/files/cc_show_seed.xml +++ b/airtime_mvc/tests/application/models/files/cc_show_seed.xml @@ -9,7 +9,7 @@ 1 shows_populated_until - 2016-02-01 05:00:00 + 2016-02-07 00:00:00 \ No newline at end of file diff --git a/airtime_mvc/tests/application/models/files/test_deleteShowInstance.xml b/airtime_mvc/tests/application/models/files/test_deleteShowInstance.xml index ac61f015c..4044f8bb6 100644 --- a/airtime_mvc/tests/application/models/files/test_deleteShowInstance.xml +++ b/airtime_mvc/tests/application/models/files/test_deleteShowInstance.xml @@ -52,7 +52,7 @@ 01:00 5 0 - 2016-02-05 + 2016-02-12 1 0 @@ -135,6 +135,19 @@ + + 6 + 2016-02-05 00:00:00 + 2016-02-05 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + diff --git a/airtime_mvc/tests/application/models/files/test_deleteShowInstanceAndAllFollowing.xml b/airtime_mvc/tests/application/models/files/test_deleteShowInstanceAndAllFollowing.xml new file mode 100644 index 000000000..8b4933304 --- /dev/null +++ b/airtime_mvc/tests/application/models/files/test_deleteShowInstanceAndAllFollowing.xml @@ -0,0 +1,314 @@ + + +
+ id + name + url + genre + description + color + background_color + live_stream_using_airtime_auth + live_stream_using_custom_auth + live_stream_user + live_stream_pass + linked + is_linkable + + 1 + test show + + + + ffffff + 364492 + + + + + + 1 + +
+ + + id + first_show + last_show + start_time + timezone + duration + day + repeat_type + next_pop_date + show_id + record + + 1 + 2016-01-01 + 2016-01-16 + 00:00:00 + UTC + 01:00 + 5 + 0 + 2016-02-12 + 1 + 0 + + + 2 + 2016-01-04 + 2016-01-19 + 00:00:00 + UTC + 01:00 + 1 + 0 + 2016-02-08 + 1 + 0 + + + 3 + 2016-01-05 + 2016-01-20 + 00:00:00 + UTC + 01:00 + 2 + 0 + 2016-02-09 + 1 + 0 + +
+ + + id + starts + ends + show_id + record + rebroadcast + instance_id + file_id + time_filled + last_scheduled + modified_instance + + 1 + 2016-01-01 00:00:00 + 2016-01-01 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 2 + 2016-01-08 00:00:00 + 2016-01-08 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 3 + 2016-01-15 00:00:00 + 2016-01-15 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 4 + 2016-01-22 00:00:00 + 2016-01-22 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 5 + 2016-01-29 00:00:00 + 2016-01-29 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 6 + 2016-02-05 00:00:00 + 2016-02-05 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 7 + 2016-01-04 00:00:00 + 2016-01-04 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 8 + 2016-01-11 00:00:00 + 2016-01-11 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 9 + 2016-01-18 00:00:00 + 2016-01-18 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 10 + 2016-01-25 00:00:00 + 2016-01-25 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 11 + 2016-02-01 00:00:00 + 2016-02-01 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 12 + 2016-01-05 00:00:00 + 2016-01-05 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 13 + 2016-01-12 00:00:00 + 2016-01-12 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 14 + 2016-01-19 00:00:00 + 2016-01-19 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + + + 15 + 2016-01-26 00:00:00 + 2016-01-26 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + + + 16 + 2016-02-02 00:00:00 + 2016-02-02 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + 1 + +
+ + +
+ + +
+ \ No newline at end of file diff --git a/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml b/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml index 21333d2bc..8ed91fe2a 100644 --- a/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml +++ b/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml @@ -52,7 +52,7 @@ 01:00 5 0 - 2016-02-05 + 2016-02-12 1 0 @@ -135,6 +135,19 @@ + + 6 + 2016-02-05 00:00:00 + 2016-02-05 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + diff --git a/airtime_mvc/tests/application/testdata/ShowData.php b/airtime_mvc/tests/application/testdata/ShowData.php index 1bbfd29a8..6cba64241 100644 --- a/airtime_mvc/tests/application/testdata/ShowData.php +++ b/airtime_mvc/tests/application/testdata/ShowData.php @@ -150,4 +150,9 @@ Class ShowData "add_show_day_check" => array(5) ); } + + public static function getWeeklyRepeatDays() + { + return array(1,2,3,4,5); + } } \ No newline at end of file