Format code using php-cs-fixer
This commit is contained in:
parent
43d7dc92cd
commit
d52c6184b9
352 changed files with 17473 additions and 17041 deletions
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
require_once "../application/configs/conf.php";
|
||||
|
||||
require_once '../application/configs/conf.php';
|
||||
|
||||
/*
|
||||
* All dates in the xml files are hard coded and in the year 2044
|
||||
|
@ -9,6 +10,10 @@ require_once "../application/configs/conf.php";
|
|||
* require functions that calculate the start and end dates, and the next populate date. The
|
||||
* tests would be performing the same work as the application and require tests themselves.
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
||||
{
|
||||
private $_connectionMock;
|
||||
|
@ -32,11 +37,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$connection = Zend_Db::factory('pdo_pgsql', $config);
|
||||
|
||||
$this->_connectionMock = $this->createZendDbConnection(
|
||||
$connection,
|
||||
$connection,
|
||||
'airtimeunittests'
|
||||
);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
|
||||
);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
|
||||
}
|
||||
|
||||
return $this->_connectionMock;
|
||||
}
|
||||
|
||||
|
@ -54,23 +60,23 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
{
|
||||
$showService = new Application_Service_ShowService();
|
||||
|
||||
$data = array(
|
||||
"add_show_id" => -1,
|
||||
"add_show_name" => "test show",
|
||||
"add_show_description" => null,
|
||||
"add_show_url" => null,
|
||||
"add_show_genre" => null,
|
||||
"add_show_color" => "ffffff",
|
||||
"add_show_background_color" => "364492",
|
||||
"cb_airtime_auth" => false,
|
||||
"cb_custom_auth" => false,
|
||||
"custom_username" => null,
|
||||
"custom_password" => null,
|
||||
"add_show_linked" => false,
|
||||
"add_show_has_autoplaylist" => 0,
|
||||
"add_show_autoplaylist_id" => null,
|
||||
"add_show_autoplaylist_repeat" => 0
|
||||
);
|
||||
$data = [
|
||||
'add_show_id' => -1,
|
||||
'add_show_name' => 'test show',
|
||||
'add_show_description' => null,
|
||||
'add_show_url' => null,
|
||||
'add_show_genre' => null,
|
||||
'add_show_color' => 'ffffff',
|
||||
'add_show_background_color' => '364492',
|
||||
'cb_airtime_auth' => false,
|
||||
'cb_custom_auth' => false,
|
||||
'custom_username' => null,
|
||||
'custom_password' => null,
|
||||
'add_show_linked' => false,
|
||||
'add_show_has_autoplaylist' => 0,
|
||||
'add_show_autoplaylist_id' => null,
|
||||
'add_show_autoplaylist_repeat' => 0,
|
||||
];
|
||||
|
||||
$showService->setCcShow($data);
|
||||
|
||||
|
@ -80,7 +86,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show', 'select * from cc_show');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_ccShowInsertedIntoDatabase.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_ccShowInsertedIntoDatabase.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -144,7 +150,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_repeat_type"] = "1";
|
||||
$data['add_show_repeat_type'] = '1';
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -169,7 +175,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_repeat_type"] = "4";
|
||||
$data['add_show_repeat_type'] = '4';
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -194,7 +200,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_repeat_type"] = "5";
|
||||
$data['add_show_repeat_type'] = '5';
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -209,7 +215,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -219,7 +225,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_repeat_type"] = "2";
|
||||
$data['add_show_repeat_type'] = '2';
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -234,7 +240,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -244,7 +250,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_repeat_type"] = "3";
|
||||
$data['add_show_repeat_type'] = '3';
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -259,13 +265,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
||||
/* Tests that a show instance gets deleted from it's repeating sequence properly
|
||||
*/
|
||||
// Tests that a show instance gets deleted from it's repeating sequence properly
|
||||
public function testDeleteShowInstance()
|
||||
{
|
||||
TestHelper::loginUser();
|
||||
|
@ -278,7 +283,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$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');
|
||||
|
@ -286,7 +291,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_deleteShowInstance.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_deleteShowInstance.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -299,7 +304,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_day_check"] = array(5,1,2);
|
||||
$data['add_show_day_check'] = [5, 1, 2];
|
||||
|
||||
$service_show = new Application_Service_ShowService(null, $data);
|
||||
$service_show->addUpdateShow($data);
|
||||
|
@ -320,7 +325,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_deleteShowInstanceAndAllFollowing.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_deleteShowInstanceAndAllFollowing.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -350,7 +355,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_editRepeatingShowInstance.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_editRepeatingShowInstance.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -378,7 +383,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_deleteRepeatingShow.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_deleteRepeatingShow.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -388,13 +393,13 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_repeat_type"] = "1";
|
||||
$data['add_show_repeat_type'] = '1';
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
//simulate the user moves forward in the calendar
|
||||
$end = new DateTime("2044-03-12", new DateTimeZone("UTC"));
|
||||
$end = new DateTime('2044-03-12', new DateTimeZone('UTC'));
|
||||
$showService->delegateInstanceCreation(null, $end, true);
|
||||
|
||||
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
|
||||
|
@ -407,7 +412,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_repeatShowCreationWhenUserMovesForwardInCalendar.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_repeatShowCreationWhenUserMovesForwardInCalendar.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -416,9 +421,9 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
{
|
||||
TestHelper::loginUser();
|
||||
|
||||
/** Test creating a linked show **/
|
||||
/** Test creating a linked show */
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_linked"] = 1;
|
||||
$data['add_show_linked'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -433,12 +438,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createLinkedShow.yml"),
|
||||
$ds
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createLinkedShow.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
||||
/** Test the creation of a single record and rebroadcast(RR) show **/
|
||||
/** Test the creation of a single record and rebroadcast(RR) show */
|
||||
public function testCreateNoRepeatRRShow()
|
||||
{
|
||||
TestHelper::loginUser();
|
||||
|
@ -457,24 +462,24 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createNoRepeatRRShow.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createNoRepeatRRShow.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
||||
/** Test the creation of a weekly repeating, record and rebroadcast(RR) show **/
|
||||
/** Test the creation of a weekly repeating, record and rebroadcast(RR) show */
|
||||
public function testEditRepeatingShowChangeNoEndOption()
|
||||
{
|
||||
TestHelper::loginUser();
|
||||
|
||||
/** Test changing the no end option on a weekly repeating show **/
|
||||
/** Test changing the no end option on a weekly repeating show */
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
$data["add_show_end_date"] = '2044-01-09';
|
||||
$data["add_show_no_end"] = 0;
|
||||
$data["add_show_id"] = 1;
|
||||
$data['add_show_end_date'] = '2044-01-09';
|
||||
$data['add_show_no_end'] = 0;
|
||||
$data['add_show_id'] = 1;
|
||||
|
||||
$showService = new Application_Service_ShowService(null, $data, true);
|
||||
$showService->addUpdateShow($data);
|
||||
|
@ -489,7 +494,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_editRepeatingShowChangeNoEndOption.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_editRepeatingShowChangeNoEndOption.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -497,45 +502,46 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
/**
|
||||
* Tests that when you remove the first repeat show day, which changes
|
||||
* the show's first instance start date, updates the scheduled content
|
||||
* correctly
|
||||
* correctly.
|
||||
*/
|
||||
public function testRemoveFirstRepeatShowDayUpdatesScheduleCorrectly()
|
||||
{
|
||||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_start_date"] = "2044-01-29";
|
||||
$data["add_show_day_check"] = array(5,6);
|
||||
$data["add_show_linked"] = 1;
|
||||
$data['add_show_start_date'] = '2044-01-29';
|
||||
$data['add_show_day_check'] = [5, 6];
|
||||
$data['add_show_linked'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
//insert some fake tracks into cc_schedule table
|
||||
$ccFiles = new CcFiles();
|
||||
$ccFiles
|
||||
->setDbCueIn("00:00:00")
|
||||
->setDbCueOut("00:04:32")
|
||||
->save();
|
||||
->setDbCueIn('00:00:00')
|
||||
->setDbCueOut('00:04:32')
|
||||
->save()
|
||||
;
|
||||
|
||||
$scheduleItems = array(
|
||||
0 => array(
|
||||
"id" => 0,
|
||||
"instance" => 1,
|
||||
"timestamp" => time()
|
||||
)
|
||||
);
|
||||
$mediaItems = array(
|
||||
0 => array(
|
||||
"id" => 1,
|
||||
"type" => "audioclip"
|
||||
)
|
||||
);
|
||||
$scheduleItems = [
|
||||
0 => [
|
||||
'id' => 0,
|
||||
'instance' => 1,
|
||||
'timestamp' => time(),
|
||||
],
|
||||
];
|
||||
$mediaItems = [
|
||||
0 => [
|
||||
'id' => 1,
|
||||
'type' => 'audioclip',
|
||||
],
|
||||
];
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$scheduler->scheduleAfter($scheduleItems, $mediaItems);
|
||||
|
||||
//delete the first repeat day
|
||||
$data["add_show_day_check"] = array(6);
|
||||
$data["add_show_id"] = 1;
|
||||
$data['add_show_day_check'] = [6];
|
||||
$data['add_show_id'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data, true);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
|
@ -551,7 +557,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_schedule', 'select id, starts, ends, file_id, clip_length, fade_in, fade_out, cue_in, cue_out, instance_id, playout_status from cc_schedule');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_removeFirstRepeatShowDayUpdatesScheduleCorrectly.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_removeFirstRepeatShowDayUpdatesScheduleCorrectly.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -561,38 +567,39 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
TestHelper::loginUser();
|
||||
|
||||
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
|
||||
$data["add_show_start_date"] = "2044-01-29";
|
||||
$data["add_show_day_check"] = array(5, 6);
|
||||
$data["add_show_linked"] = 1;
|
||||
$data['add_show_start_date'] = '2044-01-29';
|
||||
$data['add_show_day_check'] = [5, 6];
|
||||
$data['add_show_linked'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
//insert some fake tracks into cc_schedule table
|
||||
$ccFiles = new CcFiles();
|
||||
$ccFiles
|
||||
->setDbCueIn("00:00:00")
|
||||
->setDbCueOut("00:04:32")
|
||||
->save();
|
||||
->setDbCueIn('00:00:00')
|
||||
->setDbCueOut('00:04:32')
|
||||
->save()
|
||||
;
|
||||
|
||||
$scheduleItems = array(
|
||||
0 => array(
|
||||
"id" => 0,
|
||||
"instance" => 1,
|
||||
"timestamp" => time()
|
||||
)
|
||||
);
|
||||
$mediaItems = array(
|
||||
0 => array(
|
||||
"id" => 1,
|
||||
"type" => "audioclip"
|
||||
)
|
||||
);
|
||||
$scheduleItems = [
|
||||
0 => [
|
||||
'id' => 0,
|
||||
'instance' => 1,
|
||||
'timestamp' => time(),
|
||||
],
|
||||
];
|
||||
$mediaItems = [
|
||||
0 => [
|
||||
'id' => 1,
|
||||
'type' => 'audioclip',
|
||||
],
|
||||
];
|
||||
$scheduler = new Application_Model_Scheduler();
|
||||
$scheduler->scheduleAfter($scheduleItems, $mediaItems);
|
||||
|
||||
//delete the first repeat day
|
||||
$data["add_show_day_check"] = array(6);
|
||||
$data["add_show_id"] = 1;
|
||||
$data['add_show_day_check'] = [6];
|
||||
$data['add_show_id'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data, true);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
|
@ -608,7 +615,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$ds->addTable('cc_schedule', 'select id, starts, ends, file_id, clip_length, fade_in, fade_out, cue_in, cue_out, instance_id, playout_status from cc_schedule');
|
||||
|
||||
$this->assertDataSetsEqual(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_changeRepeatDayUpdatesScheduleCorrectly.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_changeRepeatDayUpdatesScheduleCorrectly.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -622,13 +629,13 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$showService = new Application_Service_ShowService(null, $data);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
$data["add_show_repeats"] = 0;
|
||||
$data["add_show_id"] = 1;
|
||||
$data['add_show_repeats'] = 0;
|
||||
$data['add_show_id'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data, true);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
|
||||
$this->getConnection()
|
||||
$this->getConnection()
|
||||
);
|
||||
|
||||
$ds->addTable('cc_show', 'select * from cc_show');
|
||||
|
@ -636,9 +643,9 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$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(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_weeklyToNoRepeat.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_weeklyToNoRepeat.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
@ -652,13 +659,13 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$showService = new Application_Service_ShowService(null, $data);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
$data["add_show_id"] = 1;
|
||||
$data["add_show_repeat_type"] = 1;
|
||||
$data['add_show_id'] = 1;
|
||||
$data['add_show_repeat_type'] = 1;
|
||||
$showService = new Application_Service_ShowService(null, $data, true);
|
||||
$showService->addUpdateShow($data);
|
||||
|
||||
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
|
||||
$this->getConnection()
|
||||
$this->getConnection()
|
||||
);
|
||||
|
||||
$ds->addTable('cc_show', 'select * from cc_show');
|
||||
|
@ -666,9 +673,9 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
|
|||
$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(
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_weeklyToBiWeekly.yml"),
|
||||
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_weeklyToBiWeekly.yml'),
|
||||
$ds
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<?php
|
||||
require_once "../application/configs/conf.php";
|
||||
|
||||
require_once '../application/configs/conf.php';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
// needed for accessing private methods
|
||||
|
@ -17,14 +22,14 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function testFormatShowDuration()
|
||||
{
|
||||
$duration = Application_Service_ShowService::formatShowDuration("01h 00m");
|
||||
$this->assertEquals("01:00", $duration);
|
||||
$duration = Application_Service_ShowService::formatShowDuration('01h 00m');
|
||||
$this->assertEquals('01:00', $duration);
|
||||
|
||||
$duration = Application_Service_ShowService::formatShowDuration("00h 05m");
|
||||
$this->assertEquals("00:05", $duration);
|
||||
$duration = Application_Service_ShowService::formatShowDuration('00h 05m');
|
||||
$this->assertEquals('00:05', $duration);
|
||||
|
||||
$duration = Application_Service_ShowService::formatShowDuration("03h 55m");
|
||||
$this->assertEquals("03:55", $duration);
|
||||
$duration = Application_Service_ShowService::formatShowDuration('03h 55m');
|
||||
$this->assertEquals('03:55', $duration);
|
||||
}
|
||||
|
||||
public function testCalculateEndDate()
|
||||
|
@ -32,13 +37,13 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
|||
$method = $this->_reflectionOfShowService->getMethod('calculateEndDate');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$end = $method->invokeArgs($this->_showService, array(ShowServiceData::getNoRepeatNoRRData()));
|
||||
$end = $method->invokeArgs($this->_showService, [ShowServiceData::getNoRepeatNoRRData()]);
|
||||
$this->assertEquals(null, $end);
|
||||
|
||||
$end = $method->invokeArgs($this->_showService, array(ShowServiceData::getWeeklyRepeatWithEndNoRRData()));
|
||||
$this->assertEquals(new DateTime("2044-01-27", new DateTimeZone("UTC")), $end);
|
||||
$end = $method->invokeArgs($this->_showService, [ShowServiceData::getWeeklyRepeatWithEndNoRRData()]);
|
||||
$this->assertEquals(new DateTime('2044-01-27', new DateTimeZone('UTC')), $end);
|
||||
|
||||
$end = $method->invokeArgs($this->_showService, array(ShowServiceData::getWeeklyRepeatNoEndNoRRData()));
|
||||
$end = $method->invokeArgs($this->_showService, [ShowServiceData::getWeeklyRepeatNoEndNoRRData()]);
|
||||
$this->assertEquals(null, $end);
|
||||
}
|
||||
|
||||
|
@ -47,20 +52,20 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
|||
$method = $this->_reflectionOfShowService->getMethod('getMonthlyWeeklyRepeatInterval');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-01"), new DateTimeZone("UTC")));
|
||||
$this->assertEquals(array("first", "Friday"), $repeatInterval);
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-01'), new DateTimeZone('UTC')]);
|
||||
$this->assertEquals(['first', 'Friday'], $repeatInterval);
|
||||
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-12"), new DateTimeZone("UTC")));
|
||||
$this->assertEquals(array("second", "Tuesday"), $repeatInterval);
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-12'), new DateTimeZone('UTC')]);
|
||||
$this->assertEquals(['second', 'Tuesday'], $repeatInterval);
|
||||
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-18"), new DateTimeZone("UTC")));
|
||||
$this->assertEquals(array("third", "Monday"), $repeatInterval);
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-18'), new DateTimeZone('UTC')]);
|
||||
$this->assertEquals(['third', 'Monday'], $repeatInterval);
|
||||
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-28"), new DateTimeZone("UTC")));
|
||||
$this->assertEquals(array("fourth", "Thursday"), $repeatInterval);
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-28'), new DateTimeZone('UTC')]);
|
||||
$this->assertEquals(['fourth', 'Thursday'], $repeatInterval);
|
||||
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-30"), new DateTimeZone("UTC")));
|
||||
$this->assertEquals(array("fifth", "Saturday"), $repeatInterval);
|
||||
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-30'), new DateTimeZone('UTC')]);
|
||||
$this->assertEquals(['fifth', 'Saturday'], $repeatInterval);
|
||||
}
|
||||
|
||||
public function testGetNextMonthlyMonthlyRepeatDate()
|
||||
|
@ -68,11 +73,11 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
|||
$method = $this->_reflectionOfShowService->getMethod('getNextMonthlyMonthlyRepeatDate');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$next = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-01"), "UTC", "00:00"));
|
||||
$this->assertEquals(new DateTime("2044-02-01", new DateTimeZone("UTC")), $next);
|
||||
$next = $method->invokeArgs($this->_showService, [new DateTime('2044-01-01'), 'UTC', '00:00']);
|
||||
$this->assertEquals(new DateTime('2044-02-01', new DateTimeZone('UTC')), $next);
|
||||
|
||||
$next = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-30"), "UTC", "00:00"));
|
||||
$this->assertEquals(new DateTime("2044-03-30", new DateTimeZone("UTC")), $next);
|
||||
$next = $method->invokeArgs($this->_showService, [new DateTime('2044-01-30'), 'UTC', '00:00']);
|
||||
$this->assertEquals(new DateTime('2044-03-30', new DateTimeZone('UTC')), $next);
|
||||
}
|
||||
|
||||
public function testGetNextMonthlyWeeklyRepeatDate()
|
||||
|
@ -80,17 +85,17 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
|||
$method = $this->_reflectionOfShowService->getMethod('getNextMonthlyWeeklyRepeatDate');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$next = $method->invokeArgs($this->_showService, array(
|
||||
new DateTime("2044-02-01"), "UTC", "00:00", "first", "Friday"));
|
||||
$this->assertEquals(new DateTime("2044-02-05", new DateTimeZone("UTC")), $next);
|
||||
$next = $method->invokeArgs($this->_showService, [
|
||||
new DateTime('2044-02-01'), 'UTC', '00:00', 'first', 'Friday', ]);
|
||||
$this->assertEquals(new DateTime('2044-02-05', new DateTimeZone('UTC')), $next);
|
||||
|
||||
$next = $method->invokeArgs($this->_showService, array(
|
||||
new DateTime("2044-02-01"), "UTC", "00:00", "fifth", "Saturday"));
|
||||
$this->assertEquals(new DateTime("2044-04-30", new DateTimeZone("UTC")), $next);
|
||||
$next = $method->invokeArgs($this->_showService, [
|
||||
new DateTime('2044-02-01'), 'UTC', '00:00', 'fifth', 'Saturday', ]);
|
||||
$this->assertEquals(new DateTime('2044-04-30', new DateTimeZone('UTC')), $next);
|
||||
|
||||
$next = $method->invokeArgs($this->_showService, array(
|
||||
new DateTime("2044-02-01"), "UTC", "00:00", "fourth", "Monday"));
|
||||
$this->assertEquals(new DateTime("2044-02-22", new DateTimeZone("UTC")), $next);
|
||||
$next = $method->invokeArgs($this->_showService, [
|
||||
new DateTime('2044-02-01'), 'UTC', '00:00', 'fourth', 'Monday', ]);
|
||||
$this->assertEquals(new DateTime('2044-02-22', new DateTimeZone('UTC')), $next);
|
||||
}
|
||||
|
||||
public function testCreateUTCStartEndDateTime()
|
||||
|
@ -98,42 +103,42 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
|
|||
$method = $this->_reflectionOfShowService->getMethod('createUTCStartEndDateTime');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
$utcTimezone = new DateTimeZone('UTC');
|
||||
|
||||
//America/Toronto
|
||||
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("America/Toronto"));
|
||||
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("America/Toronto"));
|
||||
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('America/Toronto'));
|
||||
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('America/Toronto'));
|
||||
|
||||
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00"));
|
||||
$this->assertEquals(array(
|
||||
$localStartDT->setTimezone($utcTimezone),$localEndDT->setTimezone($utcTimezone)), $dt);
|
||||
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00']);
|
||||
$this->assertEquals([
|
||||
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone), ], $dt);
|
||||
|
||||
//America/Toronto with offset for rebroadcast shows
|
||||
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("America/Toronto"));
|
||||
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("America/Toronto"));
|
||||
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('America/Toronto'));
|
||||
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('America/Toronto'));
|
||||
|
||||
$localRebroadcastStartDT = new DateTime("2044-01-02 06:30", new DateTimeZone("America/Toronto"));
|
||||
$localRebroadcastEndDT = new DateTime("2044-01-02 07:30", new DateTimeZone("America/Toronto"));
|
||||
$localRebroadcastStartDT = new DateTime('2044-01-02 06:30', new DateTimeZone('America/Toronto'));
|
||||
$localRebroadcastEndDT = new DateTime('2044-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);
|
||||
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00',
|
||||
['days' => '1', 'hours' => '06', 'mins' => '30'], ]);
|
||||
$this->assertEquals([
|
||||
$localRebroadcastStartDT->setTimezone($utcTimezone), $localRebroadcastEndDT->setTimezone($utcTimezone), ], $dt);
|
||||
|
||||
//Australia/Brisbane
|
||||
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("Australia/Brisbane"));
|
||||
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("Australia/Brisbane"));
|
||||
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('Australia/Brisbane'));
|
||||
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('Australia/Brisbane'));
|
||||
|
||||
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00"));
|
||||
$this->assertEquals(array(
|
||||
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone)), $dt);
|
||||
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00']);
|
||||
$this->assertEquals([
|
||||
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone), ], $dt);
|
||||
|
||||
//America/Vancouver
|
||||
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("America/Vancouver"));
|
||||
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("America/Vancouver"));
|
||||
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('America/Vancouver'));
|
||||
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('America/Vancouver'));
|
||||
|
||||
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00"));
|
||||
$this->assertEquals(array(
|
||||
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone)), $dt);
|
||||
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00']);
|
||||
$this->assertEquals([
|
||||
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone), ], $dt);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue