CC-5651: Unit Test the Scheduler

Added test for a non-repeat and non-record show
Added a helper class
This commit is contained in:
drigato 2014-01-08 15:51:11 -05:00
parent 3baf7929ce
commit ef13d5966f
6 changed files with 154 additions and 63 deletions

View File

@ -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());

View File

@ -0,0 +1,29 @@
<?php
class TestHelper
{
public static function loginUser()
{
$authAdapter = Application_Model_Auth::getAuthAdapter();
//pass to the adapter the submitted username and password
$authAdapter->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';
}
}
}

View File

@ -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()
{
}
}

View File

@ -1,60 +1,15 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<table name="cc_pref">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>file_id</column>
<column>time_filled</column>
<column>created</column>
<column>last_scheduled</column>
<column>modified_instance</column>
</table>
<table name="cc_show_rebroadcast">
<column>id</column>
<column>day_offset</column>
<column>start_time</column>
<column>show_id</column>
</table>
<table name="cc_show_hosts">
<column>id</column>
<column>show_id</column>
<column>subjs_id</column>
<column>subjid</column>
<column>keystr</column>
<column>valstr</column>
<row>
<value>1</value>
<null />
<value>shows_populated_until</value>
<value>2016-02-01 05:00:00</value>
</row>
</table>
</dataset>

View File

@ -0,0 +1,93 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value></value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>1</value>
<value>2016-01-01</value>
<null />
<value>00:00:00</value>
<value>America/Toronto</value>
<value>01:00</value>
<value>5</value>
<value>-1</value>
<value>2016-01-01</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>file_id</column>
<column>time_filled</column>
<column>last_scheduled</column>
<column>modified_instance</column>
<row>
<value>1</value>
<value>2016-01-01 05:00:00</value>
<value>2016-01-01 06:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<null />
<value>00:00:00</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
</dataset>

View File

@ -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