Merged the model classes from /backend to their new home in /application/models.
Copied over the /backend/tests directory and modified the paths to their new locations. Moved the liquidsoap directory to be under the pypo directory.
This commit is contained in:
parent
184ee30775
commit
dd8987cdbc
49 changed files with 3670 additions and 2639 deletions
BIN
application/models/tests/0000000000010001
Normal file
BIN
application/models/tests/0000000000010001
Normal file
Binary file not shown.
BIN
application/models/tests/0000000000010002
Normal file
BIN
application/models/tests/0000000000010002
Normal file
Binary file not shown.
24
application/models/tests/AllTests.php
Normal file
24
application/models/tests/AllTests.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
$path = dirname(__FILE__).'/../../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
$WHITE_SCREEN_OF_DEATH = false;
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
require_once 'StoredFileTests.php';
|
||||
require_once 'SchedulerTests.php';
|
||||
//require_once 'SchedulerExportTests.php';
|
||||
require_once 'PlaylistTests.php';
|
||||
|
||||
//$suite = new PHPUnit_TestSuite("PlayListTests");
|
||||
//$suite = new PHPUnit_TestSuite("SchedulerTests");
|
||||
$suite = new PHPUnit_TestSuite("StoredFileTest");
|
||||
$suite->addTestSuite("PlaylistTests");
|
||||
$suite->addTestSuite("SchedulerTests");
|
||||
//$suite->addTestSuite("SchedulerExportTests");
|
||||
$result = PHPUnit::run($suite);
|
||||
|
||||
echo $result->toString();
|
||||
|
||||
?>
|
181
application/models/tests/PlaylistTests.php
Normal file
181
application/models/tests/PlaylistTests.php
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
$path = dirname(__FILE__).'/../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../library/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../../configs/propel-config.php");
|
||||
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(dirname(__FILE__)."/../" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once(dirname(__FILE__).'/../GreenBox.php');
|
||||
require_once(dirname(__FILE__).'/../Playlist.php');
|
||||
|
||||
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'America/Toronto';
|
||||
date_default_timezone_set($tz);
|
||||
|
||||
//old database connection still needed to get a session instance.
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class PlaylistTests extends PHPUnit_TestCase {
|
||||
|
||||
private $greenbox;
|
||||
private $storedFile;
|
||||
private $storedFile2;
|
||||
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$this->greenbox = new GreenBox();
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
}
|
||||
|
||||
function testGBCreatePlaylist() {
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: create ".date("g:i a"));
|
||||
|
||||
if (!is_int($pl_id)) {
|
||||
$this->fail("problems creating playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Metadata: lock ".date("g:i a"));
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
$res = $this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems locking playlist for editing.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBUnLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: unlock ".date("g:i a"));
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
$this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
$res = $this->greenbox->releaseLockedPlaylist($pl_id, $sessid);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems unlocking playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBSetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: Set Metadata ".date("g:i a"));
|
||||
|
||||
$res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "Playlist Unit Test: Updated Title ".date("g:i a"));
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems setting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBGetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$name = "Playlist UnitTest: GetMetadata ".date("g:i a");
|
||||
$pl_id = $pl->create($name);
|
||||
|
||||
$res = $this->greenbox->getPLMetadataValue($pl_id, "dc:title");
|
||||
|
||||
if($res !== $name) {
|
||||
$this->fail("problems getting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAudioClip() {
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test ". date("g:i a"));
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip to playlist.");
|
||||
return;
|
||||
}
|
||||
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip 2 to playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testMoveAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test: Move ". date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
|
||||
$res = $this->greenbox->moveAudioClipInPlaylist($pl_id, 0, 1);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems moving audioclip in playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testDeleteAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: Delete ".date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
$res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems deleting audioclip from playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testFadeInfo() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test: Fade Info " . date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
|
||||
$res = $this->greenbox->changeFadeInfo($pl_id, 0, '00:00:01.14', null);
|
||||
|
||||
if(!is_array($res) && count($res) !== 2) {
|
||||
$this->fail("problems setting fade in playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
42
application/models/tests/SchedulerExportTests.php
Normal file
42
application/models/tests/SchedulerExportTests.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(__FILE__)."/../Schedule.php");
|
||||
|
||||
class SchedulerExportTests extends PHPUnit_TestCase {
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Clear the files table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
// Clear the schedule table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test");
|
||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
|
||||
// Schedule it
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
}
|
||||
|
||||
public function testExport() {
|
||||
echo Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
128
application/models/tests/SchedulerTests.php
Normal file
128
application/models/tests/SchedulerTests.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__)."/../Schedule.php");
|
||||
|
||||
class SchedulerTests extends PHPUnit_TestCase {
|
||||
|
||||
private $groupIdCreated;
|
||||
private $storedFile;
|
||||
private $storedFile2;
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Clear the files table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
// Clear the schedule table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
//$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";
|
||||
$id = ScheduleGroup::dateToId($dateStr);
|
||||
$expected = "20060402102008000";
|
||||
if ($id != $expected) {
|
||||
$this->fail("Did not convert date to ID correctly #2: $id != $expected");
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAndRemoveAudioFile() {
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
|
||||
$i = new ScheduleGroup($this->groupIdCreated);
|
||||
$result = $i->remove();
|
||||
if ($result != 1) {
|
||||
$this->fail("Did not remove item.");
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAndRemovePlaylist() {
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test ".uniqid());
|
||||
$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);
|
||||
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());
|
||||
}
|
||||
|
||||
function testIsScheduleEmptyInRange() {
|
||||
$i = new ScheduleGroup();
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
87
application/models/tests/StoredFileTests.php
Normal file
87
application/models/tests/StoredFileTests.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../StoredFile.php');
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class StoredFileTest extends PHPUnit_TestCase {
|
||||
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
}
|
||||
|
||||
function testGetAudioMetadata() {
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
$metadata = camp_get_audio_metadata($filePath);
|
||||
if (PEAR::isError($metadata)) {
|
||||
$this->fail($metadata->getMessage());
|
||||
return;
|
||||
}
|
||||
if (($metadata["dc:description"] != "Tmu sem tam videla ...")
|
||||
|| ($metadata["audio"]["dataformat"] != "mp3")
|
||||
|| ($metadata["dc:type"] != "Speech")) {
|
||||
$str = " [dc:description] = " . $metadata["dc:description"] ."\n"
|
||||
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
|
||||
. " [dc:type] = ".$metadata["dc:type"]."\n";
|
||||
$this->fail("Metadata has unexpected values:\n".$str);
|
||||
}
|
||||
//var_dump($metadata);
|
||||
//$this->assertTrue(FALSE);
|
||||
}
|
||||
|
||||
function testDeleteAndPutFile() {
|
||||
$STORAGE_SERVER_PATH = dirname(__FILE__)."/../../";
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
|
||||
// Delete any old data from previous tests
|
||||
$md5 = md5_file($filePath);
|
||||
$duplicate = StoredFile::RecallByMd5($md5);
|
||||
if ($duplicate) {
|
||||
$duplicate->delete();
|
||||
}
|
||||
|
||||
// Test inserting a file by linking
|
||||
$values = array("filepath" => $filePath,
|
||||
"dc:description" => "Unit test ".time());
|
||||
$storedFile = StoredFile::Insert($values, false);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
|
||||
return;
|
||||
}
|
||||
//var_dump($storedFile);
|
||||
$id = $storedFile->getId();
|
||||
if (!is_numeric($id)) {
|
||||
$this->fail("StoredFile not created correctly. id = ".$id);
|
||||
return;
|
||||
}
|
||||
|
||||
// Test loading metadata
|
||||
$f = new StoredFile();
|
||||
$f->__setGunid($storedFile->getGunid());
|
||||
$f->loadMetadata();
|
||||
if (!is_array($md = $f->getMetadata())) {
|
||||
$this->fail("Unable to load metadata.");
|
||||
return;
|
||||
}
|
||||
//var_dump($md);
|
||||
|
||||
// Check if the length field has been set.
|
||||
$f2 = StoredFile::RecallByGunid($storedFile->getGunid());
|
||||
$m2 = $f2->getMetadata();
|
||||
if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") {
|
||||
$this->fail("Length not reporting correctly in metadata.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
25
application/models/tests/analyze.php
Executable file
25
application/models/tests/analyze.php
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
header("Content-type: text/plain");
|
||||
echo "TEST\n";
|
||||
|
||||
#$gunid = "5716b53127c3761f92fddde3412c7773";
|
||||
$gunid = $argv[1];
|
||||
echo "GUNID: $gunid\n";
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
$rmd = new StoredFile($gunid, '../stor/'.substr($gunid, 0, 3));
|
||||
$r = $rmd->analyzeFile();
|
||||
|
||||
echo "r=$r (".gettype($r).")\n";
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERR: ".$r->getMessage()."\n".$r->getUserInfo()."\n";
|
||||
}
|
||||
if (is_array($r)) {
|
||||
print_r($r);
|
||||
}
|
||||
echo"\n";
|
||||
?>
|
BIN
application/models/tests/ex1.mp3
Normal file
BIN
application/models/tests/ex1.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/ex2.ogg
Normal file
BIN
application/models/tests/ex2.ogg
Normal file
Binary file not shown.
BIN
application/models/tests/ex2.wav
Normal file
BIN
application/models/tests/ex2.wav
Normal file
Binary file not shown.
BIN
application/models/tests/ex3.wav
Normal file
BIN
application/models/tests/ex3.wav
Normal file
Binary file not shown.
BIN
application/models/tests/exportedPl_lspl.tar
Normal file
BIN
application/models/tests/exportedPl_lspl.tar
Normal file
Binary file not shown.
4
application/models/tests/index.php
Normal file
4
application/models/tests/index.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
header ("location: ../");
|
||||
exit;
|
||||
?>
|
22
application/models/tests/pdoTest.php
Normal file
22
application/models/tests/pdoTest.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
|
||||
$con = Propel::getConnection("campcaster");
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM cc_schedule WHERE (starts >= '2010-01-01 00:00:00.000') "
|
||||
." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))";
|
||||
$rows1 = $con->query($sql);
|
||||
var_dump($rows1->fetchAll());
|
||||
|
||||
$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents";
|
||||
$rows2 = $con->query($sql2);
|
||||
var_dump($rows2->fetchAll());
|
||||
|
||||
$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'";
|
||||
$result3 = $con->query($sql3);
|
||||
var_dump($result3->fetchAll());
|
||||
|
||||
?>
|
26
application/models/tests/plistEmbedded.xml
Normal file
26
application/models/tests/plistEmbedded.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0"?>
|
||||
<playlist id="0e22c20310212a51">
|
||||
<playlistElement id="0000000000000103" relativeOffset="00:00:00.000000" >
|
||||
<audioClip id="0000000000010003"
|
||||
playlength="00:00:11.500000"
|
||||
title = "three"
|
||||
uri="file:var/test10003.mp3"
|
||||
/>
|
||||
</playlistElement>
|
||||
<playlistElement id="0000000000000104" relativeOffset="00:00:11.500000">
|
||||
<playlist id="0000000000000001"
|
||||
playlength="01:30:00.000000"
|
||||
title="My First Playlist">
|
||||
</playlist>
|
||||
</playlistElement>
|
||||
<metadata
|
||||
xmlns="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
>
|
||||
<dc:title>embedded playlist</dc:title>
|
||||
<dcterms:extent>01:30:11.500000</dcterms:extent>
|
||||
</metadata>
|
||||
</playlist>
|
||||
|
85
application/models/tests/pypoTester.php
Normal file
85
application/models/tests/pypoTester.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
require_once '../../conf.php';
|
||||
require_once '../Playlist.php';
|
||||
require_once '../StoredFile.php';
|
||||
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
$playlistName = "pypo_playlist_test";
|
||||
$minutesFromNow = 1;
|
||||
|
||||
echo " ************************************************************** \n";
|
||||
echo " This script schedules a playlist to play $minutesFromNow minute(s) from now.\n";
|
||||
echo " This is a utility to help you debug the scheduler.\n";
|
||||
echo " ************************************************************** \n";
|
||||
echo "\n";
|
||||
echo "Deleting playlists with the name '$playlistName'...";
|
||||
// Delete any old playlists
|
||||
$pl2 = Playlist::findPlaylistByName($playlistName);
|
||||
foreach ($pl2 as $playlist) {
|
||||
//var_dump($playlist);
|
||||
$playlist->delete();
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
// Create a new playlist
|
||||
echo "Creating new playlist '$playlistName'...";
|
||||
$pl = new Playlist();
|
||||
$pl->create($playlistName);
|
||||
|
||||
// Add a media clip
|
||||
$mediaFile = StoredFile::findByOriginalName("Manolo Camp - Morning Coffee.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Manolo Camp - Morning Coffee.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
$mediaFile = StoredFile::findByOriginalName("Peter Rudenko - Opening.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Peter Rudenko - Opening.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
||||
//$pl2 = Playlist::findPlaylistByName("pypo_playlist_test");
|
||||
//var_dump($pl2);
|
||||
|
||||
// Get current time
|
||||
// In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
$startTime = date("Y-m-d H:i:s");
|
||||
$endTime = date("Y-m-d H:i:s", time()+(60*60));
|
||||
|
||||
echo "Removing everything from the scheduler between $startTime and $endTime...";
|
||||
// Scheduler: remove any playlists for the next hour
|
||||
Schedule::RemoveItemsInRange($startTime, $endTime);
|
||||
// Check for succcess
|
||||
$scheduleClear = Schedule::isScheduleEmptyInRange($startTime, "01:00:00");
|
||||
if (!$scheduleClear) {
|
||||
echo "\nERROR: Schedule could not be cleared.\n\n";
|
||||
var_dump(Schedule::GetItems($startTime, $endTime));
|
||||
exit;
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
// Schedule the playlist for two minutes from now
|
||||
echo "Scheduling new playlist...\n";
|
||||
$playTime = date("Y-m-d H:i:s", time()+(60*$minutesFromNow));
|
||||
$scheduleGroup = new ScheduleGroup();
|
||||
$scheduleGroup->add($playTime, null, $pl->getId());
|
||||
|
||||
echo " SUCCESS: Playlist scheduled at $playTime\n\n";
|
||||
?>
|
BIN
application/models/tests/question.wav
Normal file
BIN
application/models/tests/question.wav
Normal file
Binary file not shown.
BIN
application/models/tests/silence.wav
Normal file
BIN
application/models/tests/silence.wav
Normal file
Binary file not shown.
BIN
application/models/tests/test10001.mp3
Normal file
BIN
application/models/tests/test10001.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/test10002.mp3
Normal file
BIN
application/models/tests/test10002.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/test10003.mp3
Normal file
BIN
application/models/tests/test10003.mp3
Normal file
Binary file not shown.
143
application/models/tests/transTest.php
Normal file
143
application/models/tests/transTest.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('../LocStor.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
$tr = new Transport($gb);
|
||||
$ls = new LocStor();
|
||||
@unlink($CC_CONFIG['transDir']."/activity.log");
|
||||
@unlink($CC_CONFIG['transDir']."/debug.log");
|
||||
$tr->_cleanUp();
|
||||
|
||||
$gunid = 'a23456789abcdefb';
|
||||
$mediaFile = '../tests/ex1.mp3';
|
||||
$mdataFile = '../tests/mdata1.xml';
|
||||
|
||||
// Test remote search
|
||||
$result = $tr->remoteSearch("");
|
||||
if (PEAR::isError($result)) {
|
||||
echo $result->message."\n";
|
||||
} else {
|
||||
var_dump($result);
|
||||
}
|
||||
|
||||
// ========== STORE ==========
|
||||
|
||||
echo"# Store: ";
|
||||
//$parid = $gb->_getHomeDirIdFromSess($sessid);
|
||||
$values = array(
|
||||
"filename" => "xx1.mp3",
|
||||
"filepath" => $mediaFile,
|
||||
"metadata" => $mdataFile,
|
||||
"gunid" => $gunid,
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
if ($storedFile->getCode()!=GBERR_GUNID) {
|
||||
echo "ERROR: ".$storedFile->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$oid = $storedFile->getId();
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
echo "$oid\n";
|
||||
|
||||
// ========== DELETE FROM HUB ==========
|
||||
echo"# loginToArchive: ";
|
||||
$r = $tr->loginToArchive();
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "{$r['sessid']}\n";
|
||||
$asessid = $r['sessid'];
|
||||
echo"# deleteAudioClip on Hub: ";
|
||||
$r = $tr->xmlrpcCall(
|
||||
'archive.deleteAudioClip',
|
||||
array(
|
||||
'sessid' => $asessid,
|
||||
'gunid' => $gunid,
|
||||
'forced' => TRUE,
|
||||
)
|
||||
);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; if($r->getCode()!=800+GBERR_FILENEX) exit(1); }
|
||||
else{ echo " {$r['status']}\n"; }
|
||||
echo"# logoutFromArchive: ";
|
||||
$r = $tr->logoutFromArchive($asessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
|
||||
|
||||
// ========== UPLOAD ==========
|
||||
echo "# UPLOAD test:\n";
|
||||
echo"# uploadAudioClip2Hub: ";
|
||||
$r = $gb->upload2Hub($gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
#$trtok='280a6f1c18389620';
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
// === DELETE LOCAL ===
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
echo "# logout: "; $r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
|
||||
echo `$comm`;
|
||||
|
||||
// === DOWNLOAD ===
|
||||
echo "# DOWNLOAD test:\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# downloadAudioClipFromHub: ";
|
||||
$r = $gb->downloadFromHub($sessid, $gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
|
||||
if(file_exists("../trans/log")) echo `tail -n 25 ../trans/log`;
|
||||
echo "#Transport test: OK.\n\n";
|
||||
*/
|
||||
?>
|
62
application/models/tests/webstreamTest.php
Normal file
62
application/models/tests/webstreamTest.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
echo "\n#StorageServer storeWebstream test:\n";
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
#$gunid = "123456789abcdee0";
|
||||
$gunid = "";
|
||||
#$mdataFileLP = '../tests/mdata1.xml';
|
||||
$mdataFileLP = NULL;
|
||||
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
$parid = $gb->_getHomeDirId($sessid);
|
||||
|
||||
echo "# storeWebstream: ";
|
||||
$r = $gb->storeWebstream(
|
||||
$parid, 'test stream', $mdataFileLP, $sessid, $gunid, 'http://localhost/y');
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "";
|
||||
var_dump($r);
|
||||
//$id = BasicStor::IdFromGunid($gunid);
|
||||
$id = $r;
|
||||
|
||||
echo "# getMdata: ";
|
||||
$r = $gb->getMetadata($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo "# deleteFile: ";
|
||||
$r = $gb->deleteFile($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo "# logout: ";
|
||||
$r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
|
||||
echo "#storeWebstream test: OK.\n\n"
|
||||
*/
|
||||
?>
|
14
application/models/tests/wstream1.xml
Normal file
14
application/models/tests/wstream1.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<audioClip>
|
||||
<metadata
|
||||
xmlns="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
||||
>
|
||||
<dc:title>Webstream test 1</dc:title>
|
||||
<dcterms:extent>01:30:00.000000</dcterms:extent>
|
||||
<ls:url>http://localhost/y</ls:url>
|
||||
</metadata>
|
||||
</audioClip>
|
Loading…
Add table
Add a link
Reference in a new issue