diff --git a/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php b/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php index eec41a8dd..8acf9e59f 100644 --- a/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php +++ b/airtime_mvc/tests/application/services/database/ShowServiceDbTest.php @@ -109,7 +109,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase /* Tests that a non-repeating, non-record, and non-rebroadcast show * gets created properly */ - public function testNoRepeatNoRRShowCreated() + public function testCreateNoRepeatNoRRShow() { TestHelper::loginUser(); @@ -128,7 +128,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase $ds->addTable('cc_show_hosts', 'select * from cc_show_hosts'); $this->assertDataSetsEqual( - $this->createXmlDataSet(dirname(__FILE__)."/datasets/test_noRepeatNoRRShowCreated.xml"), + $this->createXmlDataSet(dirname(__FILE__)."/datasets/test_createNoRepeatNoRRShow.xml"), $ds ); } @@ -136,7 +136,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase /* Tests that a weekly repeating, non-record, non-rebroadcast show * with no end date gets created correctly */ - public function testWeeklyRepeatNoEndNoRRShowCreated() + public function testCreateWeeklyRepeatNoEndNoRRShow() { TestHelper::loginUser(); @@ -155,7 +155,132 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase $ds->addTable('cc_show_hosts', 'select * from cc_show_hosts'); $this->assertDataSetsEqual( - $this->createXmlDataSet(dirname(__FILE__)."/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml"), + $this->createXmlDataSet(dirname(__FILE__)."/datasets/test_createWeeklyRepeatNoEndNoRRShow.xml"), + $ds + ); + } + + public function testCreateBiWeeklyRepeatNoEndNoRRShow() + { + TestHelper::loginUser(); + + $data = ShowServiceData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_repeat_type"] = "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_createBiWeeklyRepeatNoEndNoRRShow.xml"), + $ds + ); + } + + public function testCreateTriWeeklyRepeatNoEndNoRRShow() + { + TestHelper::loginUser(); + + $data = ShowServiceData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_repeat_type"] = "4"; + $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_createTriWeeklyRepeatNoEndNoRRShow.xml"), + $ds + ); + } + + public function testCreateQuadWeeklyRepeatNoEndNoRRShow() + { + TestHelper::loginUser(); + + $data = ShowServiceData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_repeat_type"] = "5"; + $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_createQuadWeeklyRepeatNoEndNoRRShow.xml"), + $ds + ); + } + + public function testCreateMonthlyMonthlyRepeatNoEndNoRRShow() + { + TestHelper::loginUser(); + + $data = ShowServiceData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_repeat_type"] = "2"; + $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_createMonthlyMonthlyRepeatNoEndNoRRShow.xml"), + $ds + ); + } + + public function testCreateMonthlyWeeklyRepeatNoEndNoRRShow() + { + TestHelper::loginUser(); + + $data = ShowServiceData::getWeeklyRepeatNoEndNoRRData(); + $data["add_show_repeat_type"] = "3"; + $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_createMonthlyWeeklyRepeatNoEndNoRRShow.xml"), $ds ); } diff --git a/airtime_mvc/tests/application/services/database/datasets/test_createBiWeeklyRepeatNoEndNoRRShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_createBiWeeklyRepeatNoEndNoRRShow.xml new file mode 100644 index 000000000..7432957b5 --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_createBiWeeklyRepeatNoEndNoRRShow.xml @@ -0,0 +1,107 @@ + + + + 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 + 1 + 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-15 00:00:00 + 2016-01-15 01:00:00 + 1 + 0 + 0 + + + + + 3 + 2016-01-29 00:00:00 + 2016-01-29 01:00:00 + 1 + 0 + 0 + + + +
+ + +
+ + +
+
\ No newline at end of file diff --git a/airtime_mvc/tests/application/services/database/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.xml new file mode 100644 index 000000000..b2140cdfd --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.xml @@ -0,0 +1,97 @@ + + + + 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 + + 2 + 2016-03-01 + 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-02-01 00:00:00 + 2016-02-01 01:00:00 + 1 + 0 + 0 + + + +
+ + +
+ + +
+
\ No newline at end of file diff --git a/airtime_mvc/tests/application/services/database/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.xml new file mode 100644 index 000000000..f778175df --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.xml @@ -0,0 +1,97 @@ + + + + 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 + 3 + 2016-03-04 + 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-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_noRepeatNoRRShowCreated.xml b/airtime_mvc/tests/application/services/database/datasets/test_createNoRepeatNoRRShow.xml similarity index 100% rename from airtime_mvc/tests/application/services/database/datasets/test_noRepeatNoRRShowCreated.xml rename to airtime_mvc/tests/application/services/database/datasets/test_createNoRepeatNoRRShow.xml diff --git a/airtime_mvc/tests/application/services/database/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.xml new file mode 100644 index 000000000..854af10eb --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.xml @@ -0,0 +1,97 @@ + + + + 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 + 5 + 2016-02-26 + 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-29 00:00:00 + 2016-01-29 01:00:00 + 1 + 0 + 0 + + + +
+ + +
+ + +
+
\ No newline at end of file diff --git a/airtime_mvc/tests/application/services/database/datasets/test_createTriWeeklyRepeatNoEndNoRRShow.xml b/airtime_mvc/tests/application/services/database/datasets/test_createTriWeeklyRepeatNoEndNoRRShow.xml new file mode 100644 index 000000000..2eb7e2b75 --- /dev/null +++ b/airtime_mvc/tests/application/services/database/datasets/test_createTriWeeklyRepeatNoEndNoRRShow.xml @@ -0,0 +1,97 @@ + + + + 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 + 4 + 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-22 00:00:00 + 2016-01-22 01:00:00 + 1 + 0 + 0 + + + +
+ + +
+ + +
+
\ No newline at end of file diff --git a/airtime_mvc/tests/application/services/database/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml b/airtime_mvc/tests/application/services/database/datasets/test_createWeeklyRepeatNoEndNoRRShow.xml similarity index 100% rename from airtime_mvc/tests/application/services/database/datasets/test_weeklyRepeatNoEndNoRRShowCreated.xml rename to airtime_mvc/tests/application/services/database/datasets/test_createWeeklyRepeatNoEndNoRRShow.xml diff --git a/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php b/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php index c8faa6321..ba065b7e6 100644 --- a/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php +++ b/airtime_mvc/tests/application/services/unit/ShowServiceUnitTest.php @@ -102,6 +102,7 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase $utcTimezone = new DateTimeZone("UTC"); + //America/Toronto $localStartDT = new DateTime("2016-01-01 06:30", new DateTimeZone("America/Toronto")); $localEndDT = new DateTime("2016-01-01 07:30", new DateTimeZone("America/Toronto")); @@ -109,6 +110,19 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase $this->assertEquals(array( $localStartDT->setTimezone($utcTimezone),$localEndDT->setTimezone($utcTimezone)), $dt); + //America/Toronto with offset for rebroadcast shows + $localStartDT = new DateTime("2016-01-01 06:30", new DateTimeZone("America/Toronto")); + $localEndDT = new DateTime("2016-01-01 07:30", new DateTimeZone("America/Toronto")); + + $localRebroadcastStartDT = new DateTime("2016-01-02 06:30", new DateTimeZone("America/Toronto")); + $localRebroadcastEndDT = new DateTime("2016-01-02 07:30", new DateTimeZone("America/Toronto")); + + $dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00", + array("days" => "1", "hours" => "06", "mins" => "30"))); + $this->assertEquals(array( + $localRebroadcastStartDT->setTimezone($utcTimezone),$localRebroadcastEndDT->setTimezone($utcTimezone)), $dt); + + //Australia/Brisbane $localStartDT = new DateTime("2016-01-01 06:30", new DateTimeZone("Australia/Brisbane")); $localEndDT = new DateTime("2016-01-01 07:30", new DateTimeZone("Australia/Brisbane")); @@ -116,6 +130,7 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase $this->assertEquals(array( $localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone)), $dt); + //America/Vancouver $localStartDT = new DateTime("2016-01-01 06:30", new DateTimeZone("America/Vancouver")); $localEndDT = new DateTime("2016-01-01 07:30", new DateTimeZone("America/Vancouver"));