Fixed testcases to account for show image path in and show instance description

This commit is contained in:
Duncan Sommerville 2014-10-09 09:39:50 -04:00
parent 6ade74163d
commit 0196aa21f5
28 changed files with 125 additions and 76 deletions

3
.gitignore vendored
View File

@ -6,3 +6,6 @@
**/build/*
**/dist/*
*~
/airtime_mvc/tests/test_results.xml
/tests/results.html
/tests/*.jar

View File

@ -142,16 +142,14 @@ class Application_Service_ShowService
$ccShowInstance->updateDbTimeFilled($con);
$ccShowInstance->updateScheduleStatus($con);
$ccShowInstance
->setDbDescription($showData['add_show_instance_description'])
->save();
->setDbDescription($showData['add_show_instance_description'])
->save();
//delete the edited instance from the repeating sequence
$ccShowInstanceOrig
->setDbModifiedInstance(true)
->setDbDescription($showData['add_show_instance_description'])
->save();
->setDbModifiedInstance(true)
->setDbDescription($showData['add_show_instance_description'])
->save();
$con->commit();
Application_Model_RabbitMq::PushSchedule();
@ -206,16 +204,16 @@ class Application_Service_ShowService
$daysAdded = array();
if ($this->isUpdate) {
$showId = $this->ccShow->getDbId();
// Only delete the previous logo if a new one is being uploaded
if (array_key_exists("add_show_logo_name", $showData) && $showData["add_show_logo_name"] !== "") {
if (!Rest_ShowController::deleteShowImagesFromStor($showId)) {
throw new Exception("Error deleting show images");
}
}
$showId = $this->ccShow->getDbId();
// Only delete the previous logo if a new one is being uploaded
if (array_key_exists("add_show_logo_name", $showData) && $showData["add_show_logo_name"] !== "") {
if (!Rest_ShowController::deleteShowImagesFromStor($showId)) {
throw new Exception("Error deleting show images");
}
}
if (!$this->ccShow->getCcShowDayss()->isEmpty()) {
$this->storeOrigLocalShowInfo();
}
@ -604,17 +602,17 @@ SQL;
$currentShowEndDateTime = $this->getRepeatingEndDate();
if ($endDateTime && $currentShowEndDateTime != $endDateTime) {
$endDate = clone $endDateTime;
$endDate->setTimezone(new DateTimeZone("UTC"));
$endDate = clone $endDateTime;
$endDate->setTimezone(new DateTimeZone("UTC"));
//show's "No End" option was toggled
//or the end date comes earlier
if (is_null($currentShowEndDateTime) || ($endDateTime < $currentShowEndDateTime)) {
//"No End" option was unchecked so we need to delete the
//repeat instances that are scheduled after the new end date
//OR
//end date was pushed back so we have to delete any
//instances of this show scheduled after the new end date
//end date was pushed back so we have to delete any
//instances of this show scheduled after the new end date
$this->deleteInstancesFromDate($endDate->format("Y-m-d"), $showId);
}
}
@ -661,10 +659,10 @@ SQL;
$date = null;
if ($query !== false && isset($query["last_show"])) {
$date = new DateTime(
$query["last_show"],
new DateTimeZone($query["timezone"])
);
$date = new DateTime(
$query["last_show"],
new DateTimeZone($query["timezone"])
);
}
return $date;
@ -752,7 +750,7 @@ SQL;
$con = Propel::getConnection();
$con->beginTransaction();
try {
if (!$currentUser->isAdminOrPM()) {
throw new Exception("Permission denied");
}
@ -765,10 +763,10 @@ SQL;
// Delete show images
$showId = $ccShowInstance->getDbShowId();
if (!Rest_ShowController::deleteShowImagesFromStor($showId)) {
throw new Exception("Error deleting show images");
}
if (!Rest_ShowController::deleteShowImagesFromStor($showId)) {
throw new Exception("Error deleting show images");
}
if ($singleInstance) {
$ccShowInstances = array($ccShowInstance);
} else {
@ -957,23 +955,23 @@ SQL;
*/
private function calculateEndDate($showData)
{
//if no end return null
//if no end return null
if ($showData['add_show_no_end']) {
$endDate = null;
}
//if the show is repeating & ends, then return the end date
elseif ($showData['add_show_repeats']) {
$endDate = new DateTime(
$showData['add_show_end_date'],
new DateTimeZone($showData["add_show_timezone"])
$showData['add_show_end_date'],
new DateTimeZone($showData["add_show_timezone"])
);
$endDate->add(new DateInterval("P1D"));
}
//the show doesn't repeat, so add one day to the start date.
else {
$endDate = new DateTime(
$showData['add_show_start_date'],
new DateTimeZone($showData["add_show_timezone"])
$showData['add_show_start_date'],
new DateTimeZone($showData["add_show_timezone"])
);
$endDate->add(new DateInterval("P1D"));
}
@ -1143,11 +1141,11 @@ SQL;
$repeatInterval, $populateUntil);
if ($last_show) {
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
$utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
$utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
}
else {
$utcLastShowDateTime = null;
$utcLastShowDateTime = null;
}
$previousDate = clone $start;
@ -1243,12 +1241,12 @@ SQL;
$this->repeatType = $showDay->getDbRepeatType();
if ($last_show) {
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
$utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
if ($last_show) {
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
$utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
}
else {
$utcLastShowDateTime = null;
$utcLastShowDateTime = null;
}
while ($start->getTimestamp() < $end->getTimestamp()) {
@ -1571,8 +1569,8 @@ SQL;
$showId = $this->ccShow->getDbId();
$startDateTime = new DateTime(
$showData['add_show_start_date']." ".$showData['add_show_start_time'],
new DateTimeZone($showData['add_show_timezone'])
$showData['add_show_start_date']." ".$showData['add_show_start_time'],
new DateTimeZone($showData['add_show_timezone'])
);
$endDateTime = $this->calculateEndDate($showData);
@ -1580,7 +1578,7 @@ SQL;
$endDate = $endDateTime->format("Y-m-d");
}
else {
$endDate = null;
$endDate = null;
}
//Our calculated start DOW must be used for non repeating since a day has not been selected.

View File

@ -84,6 +84,21 @@ class TestHelper
//Now that cc_files is empty, clearing cc_music_dirs should work
$sql = "DELETE FROM cc_music_dirs";
AirtimeInstall::InstallQuery($sql, false);
// Because files are stored relative to their watch directory,
// we need to set the "stor" path before we can successfully
// create a fake file in the database.
//Copy paste from airtime-db-install.php:
$stor_dir = "/tmp";
$con = Propel::getConnection();
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
try {
$con->exec($sql);
} catch (Exception $e) {
echo " * Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
echo " * Message {$e->getMessage()}".PHP_EOL;
return false;
}
$con->commit();

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -48,22 +48,9 @@ class ScheduleUnitTest extends Zend_Test_PHPUnit_ControllerTestCase //PHPUnit_Fr
//$showService->setCcShow($testShowData); //Denise says this is not needed.
$showService->addUpdateShow($testShowData); //Create show instances
// Because files are stored relative to their watch directory,
// we need to set the "stor" path before we can successfully
// create a fake file in the database.
//Copy paste from airtime-db-install.php:
$stor_dir = "/tmp";
$con = Propel::getConnection();
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
try {
$con->exec($sql);
} catch (Exception $e) {
echo " * Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
echo " * Message {$e->getMessage()}".PHP_EOL;
return false;
}
// Insert a fake file into the database
// Moved creation of stor directory to TestHelper for setup
// Insert a fake file into the database
$request = $this->getRequest();
$params = $request->getParams();
$params['action'] = '';

View File

@ -285,6 +285,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');

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
</dataset>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value>1</value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value>1</value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value>1</value>
<value>1</value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,6 +29,7 @@
<null />
<value></value>
<value></value>
<value></value>
</row>
</table>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<column>image_path</column>
<row>
<value>1</value>
<value>test show</value>
@ -28,8 +29,9 @@
<null />
<value></value>
<value>1</value>
<value></value>
</row>
</table>
</table>
<table name="cc_show_days">
<column>id</column>

View File

@ -243,6 +243,7 @@ Class ShowServiceData
"add_show_id" => 1,
"add_show_instance_id" => 2,
"add_show_name" => "test show",
"add_show_instance_description" => "",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,