From 4e668b9d77060412d742cbb7cf99487d8a1f9bdb Mon Sep 17 00:00:00 2001 From: drigato Date: Thu, 9 Jan 2014 14:38:03 -0500 Subject: [PATCH] CC-5651: Unit Test the Scheduler Added new test for creating a weekly repeating show Renamed xml files to better reflect which test it belongs to --- .../tests/application/models/ShowTest.php | 31 +++- ...ml => test_ccShowInsertedIntoDatabase.xml} | 0 ...d.xml => test_noRepeatNoRRShowCreated.xml} | 6 +- .../test_weeklyRepeatNoEndNoRRShowCreated.xml | 145 ++++++++++++++++++ .../tests/application/testdata/ShowData.php | 77 +++++++++- 5 files changed, 249 insertions(+), 10 deletions(-) rename airtime_mvc/tests/application/models/files/{cc_show_insertIntoAssertion.xml => test_ccShowInsertedIntoDatabase.xml} (100%) rename airtime_mvc/tests/application/models/files/{noRepeatNoRRShowCreated.xml => test_noRepeatNoRRShowCreated.xml} (94%) create mode 100644 airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml diff --git a/airtime_mvc/tests/application/models/ShowTest.php b/airtime_mvc/tests/application/models/ShowTest.php index 8574e55e5..9500f4ed9 100644 --- a/airtime_mvc/tests/application/models/ShowTest.php +++ b/airtime_mvc/tests/application/models/ShowTest.php @@ -101,7 +101,7 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase $ds->addTable('cc_show', 'select * from cc_show'); $this->assertDataSetsEqual( - $this->createXmlDataSet(dirname(__FILE__)."/files/cc_show_insertIntoAssertion.xml"), + $this->createXmlDataSet(dirname(__FILE__)."/files/test_ccShowInsertedIntoDatabase.xml"), $ds ); } @@ -114,7 +114,7 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase TestHelper::loginUser(); $data = ShowData::getNoRepeatNoRRData(); - $showService = new Application_Service_ShowService(); + $showService = new Application_Service_ShowService(null, $data); $showService->addUpdateShow($data); @@ -128,16 +128,35 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase $ds->addTable('cc_show_hosts', 'select * from cc_show_hosts'); $this->assertDataSetsEqual( - $this->createXmlDataSet(dirname(__FILE__)."/files/noRepeatNoRRShowCreated.xml"), + $this->createXmlDataSet(dirname(__FILE__)."/files/test_noRepeatNoRRShowCreated.xml"), $ds ); } /* Tests that a weekly repeating, non-record, non-rebroadcast show - * gets created correctly + * with no end date gets created correctly */ - public function testWeeklyRepeatNoRRShowCreated() + public function testWeeklyRepeatNoEndNoRRShowCreated() { - + TestHelper::loginUser(); + + $data = ShowData::getWeeklyRepeatNoEndNoRRData(); + $showService = new Application_Service_ShowService(null, $data); + + $showService->addUpdateShow($data); + + $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'); + $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'); + $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_weeklyRepeatNoEndNoRRShowCreated.xml"), + $ds + ); } } diff --git a/airtime_mvc/tests/application/models/files/cc_show_insertIntoAssertion.xml b/airtime_mvc/tests/application/models/files/test_ccShowInsertedIntoDatabase.xml similarity index 100% rename from airtime_mvc/tests/application/models/files/cc_show_insertIntoAssertion.xml rename to airtime_mvc/tests/application/models/files/test_ccShowInsertedIntoDatabase.xml diff --git a/airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml b/airtime_mvc/tests/application/models/files/test_noRepeatNoRRShowCreated.xml similarity index 94% rename from airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml rename to airtime_mvc/tests/application/models/files/test_noRepeatNoRRShowCreated.xml index f3ef6512a..e68e42c2d 100644 --- a/airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml +++ b/airtime_mvc/tests/application/models/files/test_noRepeatNoRRShowCreated.xml @@ -48,7 +48,7 @@ 2016-01-01 00:00:00 - America/Toronto + UTC 01:00 5 -1 @@ -72,8 +72,8 @@ modified_instance 1 - 2016-01-01 05:00:00 - 2016-01-01 06:00:00 + 2016-01-01 00:00:00 + 2016-01-01 01:00:00 1 0 0 diff --git a/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml b/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml new file mode 100644 index 000000000..21333d2bc --- /dev/null +++ b/airtime_mvc/tests/application/models/files/test_weeklyRepeatNoEndNoRRShowCreated.xml @@ -0,0 +1,145 @@ + + + + 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 + + 00:00:00 + UTC + 01:00 + 5 + 0 + 2016-02-05 + 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 + + + + + 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 + + + + + 5 + 2016-01-29 00:00:00 + 2016-01-29 01:00:00 + 1 + 0 + 0 + + + 00:00:00 + + + +
+ + +
+ + +
+
\ No newline at end of file diff --git a/airtime_mvc/tests/application/testdata/ShowData.php b/airtime_mvc/tests/application/testdata/ShowData.php index 217ffd4c0..1bbfd29a8 100644 --- a/airtime_mvc/tests/application/testdata/ShowData.php +++ b/airtime_mvc/tests/application/testdata/ShowData.php @@ -15,7 +15,7 @@ Class ShowData "add_show_end_date_no_repeat" => "2016-01-01", "add_show_end_time" => "01:00", "add_show_duration" => "01h 00m", - "add_show_timezone" => "America/Toronto", + "add_show_timezone" => "UTC", "add_show_repeats" => 0, "add_show_linked" => 0, "add_show_repeat_type" => 0, @@ -75,4 +75,79 @@ Class ShowData "add_show_day_check" => null ); } + + public static function getWeeklyRepeatNoEndNoRRData() + { + 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-01", + "add_show_no_end" => 1, + "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) + ); + } } \ No newline at end of file