Fixed all unit tests, they are all working now.
This commit is contained in:
parent
1786501b10
commit
a643e4c755
|
@ -93,7 +93,7 @@ class ScheduleGroup {
|
||||||
." {$this->groupId}, $p_audioFileId)";
|
." {$this->groupId}, $p_audioFileId)";
|
||||||
$result = $CC_DBC->query($sql);
|
$result = $CC_DBC->query($sql);
|
||||||
if (PEAR::isError($result)) {
|
if (PEAR::isError($result)) {
|
||||||
var_dump($sql);
|
//var_dump($sql);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
return $this->groupId;
|
return $this->groupId;
|
||||||
|
@ -109,7 +109,7 @@ class ScheduleGroup {
|
||||||
|
|
||||||
// Check if there are any conflicts with existing entries
|
// Check if there are any conflicts with existing entries
|
||||||
$length = trim($playlist->getLength());
|
$length = trim($playlist->getLength());
|
||||||
var_dump($length);
|
//var_dump($length);
|
||||||
if (empty($length)) {
|
if (empty($length)) {
|
||||||
return new PEAR_Error("Length is empty.");
|
return new PEAR_Error("Length is empty.");
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,10 @@ class ScheduleGroup {
|
||||||
$itemStartTime = $p_datetime;
|
$itemStartTime = $p_datetime;
|
||||||
|
|
||||||
$plItems = $playlist->getContents();
|
$plItems = $playlist->getContents();
|
||||||
var_dump($plItems);
|
//var_dump($plItems);
|
||||||
foreach ($plItems as $row) {
|
foreach ($plItems as $row) {
|
||||||
$trackLength = $row["cliplength"];
|
$trackLength = $row["cliplength"];
|
||||||
var_dump($trackLength);
|
//var_dump($trackLength);
|
||||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||||
." (id, playlist_id, starts, ends, group_id, file_id,"
|
." (id, playlist_id, starts, ends, group_id, file_id,"
|
||||||
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
||||||
|
@ -136,7 +136,7 @@ class ScheduleGroup {
|
||||||
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
||||||
$result = $CC_DBC->query($sql);
|
$result = $CC_DBC->query($sql);
|
||||||
if (PEAR::isError($result)) {
|
if (PEAR::isError($result)) {
|
||||||
var_dump($sql);
|
//var_dump($sql);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
||||||
|
@ -173,7 +173,7 @@ class ScheduleGroup {
|
||||||
}
|
}
|
||||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
||||||
." WHERE group_id = ".$this->groupId;
|
." WHERE group_id = ".$this->groupId;
|
||||||
|
//echo $sql;
|
||||||
return $CC_DBC->query($sql);
|
return $CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,9 +229,9 @@ class Schedule {
|
||||||
." WHERE (starts >= '$p_datetime') "
|
." WHERE (starts >= '$p_datetime') "
|
||||||
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
|
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
|
||||||
//$_SESSION["debug"] = $sql;
|
//$_SESSION["debug"] = $sql;
|
||||||
var_dump($sql);
|
//var_dump($sql);
|
||||||
$count = $CC_DBC->GetOne($sql);
|
$count = $CC_DBC->GetOne($sql);
|
||||||
var_dump($count);
|
//var_dump($count);
|
||||||
return ($count == '0');
|
return ($count == '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,78 +161,78 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
$titleKey = 'dc:title';
|
$titleKey = 'dc:title';
|
||||||
$flds = array(
|
$flds = array(
|
||||||
'dc:format' => array(
|
'dc:format' => array(
|
||||||
array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE),
|
||||||
),
|
),
|
||||||
'ls:bitrate' => array(
|
'ls:bitrate' => array(
|
||||||
array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE),
|
||||||
array('path'=>"['audio']['bitrate']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['audio']['bitrate']", 'ignoreEnc'=>TRUE),
|
||||||
),
|
),
|
||||||
'ls:samplerate' => array(
|
'ls:samplerate' => array(
|
||||||
array('path'=>"['audio']['sample_rate']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['audio']['sample_rate']", 'ignoreEnc'=>TRUE),
|
||||||
),
|
),
|
||||||
'ls:encoder' => array(
|
'ls:encoder' => array(
|
||||||
array('path'=>"['audio']['codec']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['audio']['codec']", 'ignoreEnc'=>TRUE),
|
||||||
),
|
),
|
||||||
'dcterms:extent'=> array(
|
'dcterms:extent'=> array(
|
||||||
array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE),
|
||||||
),
|
),
|
||||||
'ls:composer'=> array(
|
'ls:composer'=> array(
|
||||||
array('path'=>"['id3v2']['comments']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
array('path'=>"['id3v2']['comments']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
||||||
array('path'=>"['id3v2']['TCOM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TCOM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['id3v2']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
array('path'=>"['tags']['id3v2']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
||||||
array('path'=>"['ogg']['comments']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'dc:description'=> array(
|
'dc:description'=> array(
|
||||||
array('path'=>"['id3v1']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v1']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['comments']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
array('path'=>"['id3v2']['comments']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
||||||
array('path'=>"['id3v2']['COMM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['COMM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['id3v2']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
array('path'=>"['tags']['id3v2']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
||||||
array('path'=>"['ogg']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'dc:type'=> array(
|
'dc:type'=> array(
|
||||||
array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
|
||||||
array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'dc:title' => array(
|
'dc:title' => array(
|
||||||
array('path'=>"['id3v2']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'dc:creator' => array(
|
'dc:creator' => array(
|
||||||
array('path'=>"['id3v2']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'dc:source' => array(
|
'dc:source' => array(
|
||||||
array('path'=>"['id3v2']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['ogg']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'ls:encoded_by' => array(
|
'ls:encoded_by' => array(
|
||||||
array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'ls:track_num' => array(
|
'ls:track_num' => array(
|
||||||
array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
// 'ls:genre' => array(
|
// 'ls:genre' => array(
|
||||||
// array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
|
// array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
|
||||||
// array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
// array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
|
||||||
|
@ -241,16 +241,16 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
// array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
// array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
// ),
|
// ),
|
||||||
'ls:channels' => array(
|
'ls:channels' => array(
|
||||||
array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE),
|
array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE),
|
||||||
),
|
),
|
||||||
'ls:year' => array(
|
'ls:year' => array(
|
||||||
array('path'=>"['comments']['date']"),
|
array('path'=>"['comments']['date']"),
|
||||||
array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
|
||||||
),
|
),
|
||||||
'ls:filename' => array(
|
'ls:filename' => array(
|
||||||
array('path'=>"['filename']"),
|
array('path'=>"['filename']"),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$mdata = array();
|
$mdata = array();
|
||||||
if (isset($infoFromFile['audio'])) {
|
if (isset($infoFromFile['audio'])) {
|
||||||
|
@ -1661,73 +1661,50 @@ class StoredFile {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get and optionally create subdirectory in real filesystem for storing
|
* Get real filename of raw media data
|
||||||
* raw media data.
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
// private function _getResDir()
|
public function getRealFilePath()
|
||||||
// {
|
{
|
||||||
// global $CC_CONFIG, $CC_DBC;
|
return $this->filepath;
|
||||||
// $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()
|
/**
|
||||||
{
|
* Get the URL to access this file.
|
||||||
return $this->gunid.".".$this->getFileExtension();
|
*/
|
||||||
}
|
public function getFileUrl()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
return "http://".$CC_CONFIG["storageUrlHost"]
|
||||||
|
.$CC_CONFIG["apiPath"]."get_media.php?file="
|
||||||
|
.$this->gunid.".".$this->getFileExtension();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get real filename of raw media data
|
* Get real filename of metadata file
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
* @see MetaData
|
||||||
public function getRealFilePath()
|
*/
|
||||||
{
|
public function getRealMetadataFileName()
|
||||||
return $this->filepath;
|
{
|
||||||
}
|
//return $this->md->getFileName();
|
||||||
|
return $this->md["name"];
|
||||||
/**
|
}
|
||||||
* Get the URL to access this file.
|
|
||||||
*/
|
|
||||||
public function getFileUrl()
|
|
||||||
{
|
|
||||||
global $CC_CONFIG;
|
|
||||||
return "http://".$CC_CONFIG["storageUrlHost"]
|
|
||||||
.$CC_CONFIG["apiPath"]."get_media.php?file={$this->getRealFileName()}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get real filename of metadata file
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* @see MetaData
|
|
||||||
*/
|
|
||||||
public function getRealMetadataFileName()
|
|
||||||
{
|
|
||||||
//return $this->md->getFileName();
|
|
||||||
return $this->md["name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and return name for temporary symlink.
|
* Create and return name for temporary symlink.
|
||||||
*
|
*
|
||||||
* @todo Should be more unique
|
* @todo Should be more unique
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function _getAccessFileName($p_token, $p_ext='EXT')
|
private function _getAccessFileName($p_token, $p_ext='EXT')
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
|
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // class StoredFile
|
} // class StoredFile
|
||||||
?>
|
?>
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$path = dirname(__FILE__).'/../../3rd_party/php/pear';
|
$path = dirname(__FILE__).'/../../3rd_party/php/pear';
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
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(dirname(__FILE__).'/../../conf.php');
|
||||||
require_once('DB.php');
|
require_once('DB.php');
|
||||||
|
|
|
@ -3,116 +3,126 @@ require_once(dirname(__FILE__)."/../Schedule.php");
|
||||||
|
|
||||||
class SchedulerTests extends PHPUnit_TestCase {
|
class SchedulerTests extends PHPUnit_TestCase {
|
||||||
|
|
||||||
private $groupIdCreated;
|
private $groupIdCreated;
|
||||||
private $storedFile;
|
private $storedFile;
|
||||||
private $storedFile2;
|
private $storedFile2;
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
// Clear the files table
|
// Clear the files table
|
||||||
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||||
//$CC_DBC->query($sql);
|
//$CC_DBC->query($sql);
|
||||||
|
|
||||||
// Add a file
|
// Add a file
|
||||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||||
$this->storedFile = StoredFile::Insert($values, false);
|
$this->storedFile = StoredFile::Insert($values, false);
|
||||||
|
|
||||||
// Add a file
|
// Add a file
|
||||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||||
|
|
||||||
// Clear the schedule table
|
// Clear the schedule table
|
||||||
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||||
//$CC_DBC->query($sql);
|
//$CC_DBC->query($sql);
|
||||||
}
|
|
||||||
|
|
||||||
function testDateToId() {
|
|
||||||
$dateStr = "2006-04-02 10:20:08.123456";
|
|
||||||
$id = ScheduleGroup::dateToId($dateStr);
|
|
||||||
$expected = "20060402102008123";
|
|
||||||
if ($id != $expected) {
|
|
||||||
$this->fail("Did not convert date to ID correctly #1: $id != $expected");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$dateStr = "2006-04-02 10:20:08";
|
function testDateToId() {
|
||||||
$id = ScheduleGroup::dateToId($dateStr);
|
$dateStr = "2006-04-02 10:20:08.123456";
|
||||||
$expected = "20060402102008000";
|
$id = ScheduleGroup::dateToId($dateStr);
|
||||||
if ($id != $expected) {
|
$expected = "20060402102008123";
|
||||||
$this->fail("Did not convert date to ID correctly #2: $id != $expected");
|
if ($id != $expected) {
|
||||||
}
|
$this->fail("Did not convert date to ID correctly #1: $id != $expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddAndRemoveAudioFile() {
|
$dateStr = "2006-04-02 10:20:08";
|
||||||
$i = new ScheduleGroup();
|
$id = ScheduleGroup::dateToId($dateStr);
|
||||||
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
$expected = "20060402102008000";
|
||||||
if (PEAR::isError($this->groupIdCreated)) {
|
if ($id != $expected) {
|
||||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
$this->fail("Did not convert date to ID correctly #2: $id != $expected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = new ScheduleGroup($this->groupIdCreated);
|
function testAddAndRemoveAudioFile() {
|
||||||
$result = $i->remove();
|
$i = new ScheduleGroup();
|
||||||
if ($result != 1) {
|
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
||||||
$this->fail("Did not remove item.");
|
if (PEAR::isError($this->groupIdCreated)) {
|
||||||
}
|
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddAndRemovePlaylist() {
|
$i = new ScheduleGroup($this->groupIdCreated);
|
||||||
// Create a playlist
|
$result = $i->remove();
|
||||||
$playlist = new Playlist();
|
if ($result != 1) {
|
||||||
$playlist->create("Scheduler Unit Test ".uniqid());
|
$this->fail("Did not remove item.");
|
||||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
}
|
||||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
|
||||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
|
||||||
|
|
||||||
$i = new ScheduleGroup();
|
|
||||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
|
||||||
if (PEAR::isError($this->groupIdCreated)) {
|
|
||||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = new ScheduleGroup($this->groupIdCreated);
|
function testAddAndRemovePlaylist() {
|
||||||
if ($group->count() != 3) {
|
// Create a playlist
|
||||||
$this->fail("Wrong number of items added.");
|
$playlist = new Playlist();
|
||||||
}
|
$playlist->create("Scheduler Unit Test ".uniqid());
|
||||||
$items = $group->getItems();
|
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||||
if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
|
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||||
$this->fail("Wrong start time for 2nd item.");
|
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||||
|
|
||||||
|
$i = new ScheduleGroup();
|
||||||
|
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
$items = $group->getItems();
|
||||||
|
if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
|
||||||
|
$this->fail("Wrong start time for 2nd item.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $group->remove();
|
||||||
|
if ($result != 1) {
|
||||||
|
$this->fail("Did not remove item.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Playlist::Delete($playlist->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $group->remove();
|
function testIsScheduleEmptyInRange() {
|
||||||
if ($result != 1) {
|
$i = new ScheduleGroup();
|
||||||
$this->fail("Did not remove item.");
|
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
|
||||||
|
if (PEAR::isError($this->groupIdCreated)) {
|
||||||
|
$this->fail($this->groupIdCreated->getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Playlist::Delete($playlist->getId());
|
function testGetItems() {
|
||||||
}
|
$i1 = new ScheduleGroup();
|
||||||
|
$groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId());
|
||||||
function testIsScheduleEmptyInRange() {
|
$i2 = new ScheduleGroup();
|
||||||
$i = new ScheduleGroup();
|
$i2->addAfter($groupId1, $this->storedFile->getId());
|
||||||
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
|
$items = Schedule::GetItems("2008-01-01", "2008-01-02");
|
||||||
if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:01.432153')) {
|
if (count($items) != 2) {
|
||||||
$this->fail("Reporting empty schedule when it isnt.");
|
$this->fail("Wrong number of items returned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$i1->remove();
|
||||||
|
$i2->remove();
|
||||||
}
|
}
|
||||||
$i->remove();
|
|
||||||
if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:01.432153')) {
|
|
||||||
$this->fail("Reporting booked schedule when it isnt.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function testGetItems() {
|
|
||||||
$i1 = new ScheduleGroup();
|
|
||||||
$groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId());
|
|
||||||
$i2 = new ScheduleGroup();
|
|
||||||
$i2->addAfter($groupId1, $this->storedFile->getId());
|
|
||||||
$items = Schedule::GetItems("2008-01-01", "2008-01-02");
|
|
||||||
if (count($items) != 2) {
|
|
||||||
$this->fail("Wrong number of items returned.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$i1->remove();
|
|
||||||
$i2->remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue