From ef13d5966f3b6c0e8e41c53a3c2180638510b597 Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 8 Jan 2014 15:51:11 -0500 Subject: [PATCH] CC-5651: Unit Test the Scheduler Added test for a non-repeat and non-record show Added a helper class --- airtime_mvc/tests/application/bootstrap.php | 3 + .../tests/application/helpers/TestHelper.php | 29 ++++++ .../tests/application/models/ShowTest.php | 15 ++- .../application/models/files/cc_show_seed.xml | 65 ++----------- .../models/files/noRepeatNoRRShowCreated.xml | 93 +++++++++++++++++++ .../tests/application/testdata/ShowData.php | 12 +-- 6 files changed, 154 insertions(+), 63 deletions(-) create mode 100644 airtime_mvc/tests/application/helpers/TestHelper.php create mode 100644 airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml diff --git a/airtime_mvc/tests/application/bootstrap.php b/airtime_mvc/tests/application/bootstrap.php index 54b634f05..c30574ccc 100644 --- a/airtime_mvc/tests/application/bootstrap.php +++ b/airtime_mvc/tests/application/bootstrap.php @@ -46,6 +46,9 @@ set_include_path(APPLICATION_PATH . '/controllers/plugins' . PATH_SEPARATOR . ge //test data set_include_path(APPLICATION_PATH . '/../tests/application/testdata' . PATH_SEPARATOR . get_include_path()); +//helper functions +set_include_path(APPLICATION_PATH . '/../tests/application/helpers' . PATH_SEPARATOR . get_include_path()); + //Zend framework if (file_exists('/usr/share/php/libzend-framework-php')) { set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path()); diff --git a/airtime_mvc/tests/application/helpers/TestHelper.php b/airtime_mvc/tests/application/helpers/TestHelper.php new file mode 100644 index 000000000..9b332bda0 --- /dev/null +++ b/airtime_mvc/tests/application/helpers/TestHelper.php @@ -0,0 +1,29 @@ +setIdentity('admin') + ->setCredential('admin'); + + $auth = Zend_Auth::getInstance(); + $result = $auth->authenticate($authAdapter); + if ($result->isValid()) { + //all info about this user from the login table omit only the password + $userInfo = $authAdapter->getResultRowObject(null, 'password'); + + //the default storage is a session with namespace Zend_Auth + $authStorage = $auth->getStorage(); + $authStorage->write($userInfo); + + //Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']); + //Application_Model_Subjects::resetLoginAttempts($username); + + //$tempSess = new Zend_Session_Namespace("referrer"); + //$tempSess->referrer = 'login'; + } + } +} \ No newline at end of file diff --git a/airtime_mvc/tests/application/models/ShowTest.php b/airtime_mvc/tests/application/models/ShowTest.php index c26ac054a..8574e55e5 100644 --- a/airtime_mvc/tests/application/models/ShowTest.php +++ b/airtime_mvc/tests/application/models/ShowTest.php @@ -4,6 +4,7 @@ require_once "ShowService.php"; require_once "../application/configs/conf.php"; require_once "AirtimeInstall.php"; require_once "ShowData.php"; +require_once "TestHelper.php"; class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase { @@ -110,6 +111,8 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase */ public function testNoRepeatNoRRShowCreated() { + TestHelper::loginUser(); + $data = ShowData::getNoRepeatNoRRData(); $showService = new Application_Service_ShowService(); @@ -120,13 +123,21 @@ class ShowTest extends Zend_Test_PHPUnit_DatabaseTestCase ); $ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show_days', 'select * from cc_show_days'); - $ds->addTable('cc_show_instances', 'select * from cc_show_instances'); + $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/cc_show_insertIntoAssertion.xml"), + $this->createXmlDataSet(dirname(__FILE__)."/files/noRepeatNoRRShowCreated.xml"), $ds ); } + + /* Tests that a weekly repeating, non-record, non-rebroadcast show + * gets created correctly + */ + public function testWeeklyRepeatNoRRShowCreated() + { + + } } 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 988499585..ced616de7 100644 --- a/airtime_mvc/tests/application/models/files/cc_show_seed.xml +++ b/airtime_mvc/tests/application/models/files/cc_show_seed.xml @@ -1,60 +1,15 @@ - +
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 -
- - - id - first_show - last_show - start_time - timezone - duration - day - repeat_type - next_pop_date - show_id - record -
- - - id - starts - ends - show_id - record - rebroadcast - instance_id - file_id - time_filled - created - last_scheduled - modified_instance -
- - - id - day_offset - start_time - show_id -
- - - id - show_id - subjs_id + subjid + keystr + valstr + + 1 + + shows_populated_until + 2016-02-01 05:00:00 +
\ No newline at end of file diff --git a/airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml b/airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml new file mode 100644 index 000000000..f3ef6512a --- /dev/null +++ b/airtime_mvc/tests/application/models/files/noRepeatNoRRShowCreated.xml @@ -0,0 +1,93 @@ + + + + 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 + America/Toronto + 01:00 + 5 + -1 + 2016-01-01 + 1 + 0 + +
+ + + id + starts + ends + show_id + record + rebroadcast + instance_id + file_id + time_filled + last_scheduled + modified_instance + + 1 + 2016-01-01 05:00:00 + 2016-01-01 06: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 70d4e2394..217ffd4c0 100644 --- a/airtime_mvc/tests/application/testdata/ShowData.php +++ b/airtime_mvc/tests/application/testdata/ShowData.php @@ -6,21 +6,21 @@ Class ShowData return array( "add_show_id" => -1, "add_show_instance_id" => -1, - "add_show_name" => "gggg", + "add_show_name" => "test show", "add_show_url" => null, "add_show_genre" => null, "add_show_description" => null, - "add_show_start_date" => "2014-01-08", + "add_show_start_date" => "2016-01-01", "add_show_start_time" => "00:00", - "add_show_end_date_no_repeat" => "2014-01-08", + "add_show_end_date_no_repeat" => "2016-01-01", "add_show_end_time" => "01:00", - "add_show_duration" => "01:00", + "add_show_duration" => "01h 00m", "add_show_timezone" => "America/Toronto", "add_show_repeats" => 0, "add_show_linked" => 0, "add_show_repeat_type" => 0, "add_show_monthly_repeat_type" => 2, - "add_show_end_date" => "2014-01-08", + "add_show_end_date" => "2016-01-01", "add_show_no_end" => 1, "cb_airtime_auth" => 0, "cb_custom_auth" => 0, @@ -69,7 +69,7 @@ Class ShowData "add_show_rebroadcast_date_10" => null, "add_show_rebroadcast_time_10" => null, "add_show_hosts_autocomplete" => null, - "add_show_background_color" => "3061c0", + "add_show_background_color" => "364492", "add_show_color" => "ffffff", "add_show_hosts" => null, "add_show_day_check" => null