diff --git a/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php b/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php index 7519b55c1..a076e2279 100644 --- a/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php +++ b/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php @@ -417,4 +417,51 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase $ds ); } + + public function testLinkedShow() + { + TestHelper::loginUser(); + + /** Test creating a linked show **/ + $data = ShowServiceData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_linked"] = 1; + $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, 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__)."/datasets/test_createLinkedShow.xml"), + $ds + ); + + /** Test unlinking a show **/ + // TODO: find out why linked and is_linkable columns are getting set to NULL + $data["add_show_id"] = 1; + $data["add_show_linked"] = 0; + $showService = new Application_Service_ShowService(null, $data, true); + $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, 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__)."/datasets/test_unlinkLinkedShow.xml"), + $ds + ); + } } diff --git a/airtime_mvc/tests/application/services/database/datasets/test_createLinkedShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_createLinkedShow.xml new file mode 100644 index 000000000..871729009 --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_createLinkedShow.xml @@ -0,0 +1,137 @@ + + + + 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 + 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-12 + 1 + 0 + +
+ + + id + starts + ends + show_id + record + rebroadcast + instance_id + modified_instance + + 1 + 2016-01-01 00:00:00 + 2016-01-01 01:00:00 + 1 + 0 + 0 + + + + + 2 + 2016-01-08 00:00:00 + 2016-01-08 01:00:00 + 1 + 0 + 0 + + + + + 3 + 2016-01-15 00:00:00 + 2016-01-15 01:00:00 + 1 + 0 + 0 + + + + + 4 + 2016-01-22 00:00:00 + 2016-01-22 01:00:00 + 1 + 0 + 0 + + + + + 5 + 2016-01-29 00:00:00 + 2016-01-29 01:00:00 + 1 + 0 + 0 + + + + + 6 + 2016-02-05 00:00:00 + 2016-02-05 01:00:00 + 1 + 0 + 0 + + + +
+ + +
+ + +
+
\ No newline at end of file diff --git a/airtime_mvc/tests/application/services/database/datasets/test_unlinkLinkedShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_unlinkLinkedShow.xml new file mode 100644 index 000000000..3ed0548ee --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_unlinkLinkedShow.xml @@ -0,0 +1,137 @@ + + + + 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 + + + + + + + +
+ + + 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-12 + 1 + 0 + +
+ + + id + starts + ends + show_id + record + rebroadcast + instance_id + modified_instance + + 1 + 2016-01-01 00:00:00 + 2016-01-01 01:00:00 + 1 + 0 + 0 + + + + + 2 + 2016-01-08 00:00:00 + 2016-01-08 01:00:00 + 1 + 0 + 0 + + + + + 3 + 2016-01-15 00:00:00 + 2016-01-15 01:00:00 + 1 + 0 + 0 + + + + + 4 + 2016-01-22 00:00:00 + 2016-01-22 01:00:00 + 1 + 0 + 0 + + + + + 5 + 2016-01-29 00:00:00 + 2016-01-29 01:00:00 + 1 + 0 + 0 + + + + + 6 + 2016-02-05 00:00:00 + 2016-02-05 01:00:00 + 1 + 0 + 0 + + + +
+ + +
+ + +
+
\ No newline at end of file