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

View File

@ -14,6 +14,7 @@
<column>live_stream_pass</column> <column>live_stream_pass</column>
<column>linked</column> <column>linked</column>
<column>is_linkable</column> <column>is_linkable</column>
<column>image_path</column>
<row> <row>
<value>1</value> <value>1</value>
<value>test show</value> <value>test show</value>
@ -28,6 +29,7 @@
<null /> <null />
<value></value> <value></value>
<value>1</value> <value>1</value>
<value></value>
</row> </row>
</table> </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->setCcShow($testShowData); //Denise says this is not needed.
$showService->addUpdateShow($testShowData); //Create show instances $showService->addUpdateShow($testShowData); //Create show instances
// Because files are stored relative to their watch directory, // Moved creation of stor directory to TestHelper for setup
// we need to set the "stor" path before we can successfully
// create a fake file in the database. // Insert a fake file into 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
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getParams(); $params = $request->getParams();
$params['action'] = ''; $params['action'] = '';

View File

@ -285,6 +285,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet( $ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection() $this->getConnection()
); );
$ds->addTable('cc_show', 'select * from cc_show'); $ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days'); $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'); $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>live_stream_pass</column>
<column>linked</column> <column>linked</column>
<column>is_linkable</column> <column>is_linkable</column>
<column>image_path</column>
<row> <row>
<value>1</value> <value>1</value>
<value>test show</value> <value>test show</value>
@ -28,6 +29,7 @@
<null /> <null />
<value></value> <value></value>
<value>1</value> <value>1</value>
<value></value>
</row> </row>
</table> </table>
</dataset> </dataset>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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