Fixed all unit tests, they are all working now.

This commit is contained in:
paul.baranowski 2010-11-19 15:51:58 -05:00
parent 1786501b10
commit a643e4c755
4 changed files with 218 additions and 231 deletions

View File

@ -93,7 +93,7 @@ class ScheduleGroup {
." {$this->groupId}, $p_audioFileId)";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
var_dump($sql);
//var_dump($sql);
return $result;
}
return $this->groupId;
@ -109,7 +109,7 @@ class ScheduleGroup {
// Check if there are any conflicts with existing entries
$length = trim($playlist->getLength());
var_dump($length);
//var_dump($length);
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
@ -123,10 +123,10 @@ class ScheduleGroup {
$itemStartTime = $p_datetime;
$plItems = $playlist->getContents();
var_dump($plItems);
//var_dump($plItems);
foreach ($plItems as $row) {
$trackLength = $row["cliplength"];
var_dump($trackLength);
//var_dump($trackLength);
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (id, playlist_id, starts, ends, group_id, file_id,"
." clip_length, cue_in, cue_out, fade_in, fade_out)"
@ -136,7 +136,7 @@ class ScheduleGroup {
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
var_dump($sql);
//var_dump($sql);
return $result;
}
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
@ -173,7 +173,7 @@ class ScheduleGroup {
}
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
." WHERE group_id = ".$this->groupId;
//echo $sql;
return $CC_DBC->query($sql);
}
@ -229,9 +229,9 @@ class Schedule {
." WHERE (starts >= '$p_datetime') "
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
//$_SESSION["debug"] = $sql;
var_dump($sql);
//var_dump($sql);
$count = $CC_DBC->GetOne($sql);
var_dump($count);
//var_dump($count);
return ($count == '0');
}

View File

@ -1660,30 +1660,6 @@ class StoredFile {
}
/**
* Get and optionally create subdirectory in real filesystem for storing
* raw media data.
*
* @return string
*/
// private function _getResDir()
// {
// global $CC_CONFIG, $CC_DBC;
// $resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3);
// //$this->gb->debugLog("$resDir");
// // see Transport::_getResDir too for resDir name create code
// if (!is_dir($resDir)) {
// mkdir($resDir, 02775);
// chmod($resDir, 02775);
// }
// return $resDir;
// }
public function getRealFileName()
{
return $this->gunid.".".$this->getFileExtension();
}
/**
* Get real filename of raw media data
*
@ -1701,7 +1677,8 @@ class StoredFile {
{
global $CC_CONFIG;
return "http://".$CC_CONFIG["storageUrlHost"]
.$CC_CONFIG["apiPath"]."get_media.php?file={$this->getRealFileName()}";
.$CC_CONFIG["apiPath"]."get_media.php?file="
.$this->gunid.".".$this->getFileExtension();
}
/**

View File

@ -1,7 +1,7 @@
<?php
$path = dirname(__FILE__).'/../../3rd_party/php/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$WHITE_SCREEN_OF_DEATH = true;
$WHITE_SCREEN_OF_DEATH = false;
require_once(dirname(__FILE__).'/../../conf.php');
require_once('DB.php');

View File

@ -70,7 +70,6 @@ class SchedulerTests extends PHPUnit_TestCase {
if (PEAR::isError($this->groupIdCreated)) {
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
}
$group = new ScheduleGroup($this->groupIdCreated);
if ($group->count() != 3) {
$this->fail("Wrong number of items added.");
@ -91,12 +90,23 @@ class SchedulerTests extends PHPUnit_TestCase {
function testIsScheduleEmptyInRange() {
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:01.432153')) {
$this->fail("Reporting empty schedule when it isnt.");
if (PEAR::isError($this->groupIdCreated)) {
$this->fail($this->groupIdCreated->getMessage());
return;
}
$i->remove();
if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:01.432153')) {
if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
$this->fail("Reporting empty schedule when it isnt.");
return;
}
// echo "groupid: ".$this->groupIdCreated."\n";
$success = $i->remove();
if ($success === false) {
$this->fail("Failed to delete schedule group.");
return;
}
if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
$this->fail("Reporting booked schedule when it isnt.");
return;
}
}