Fixed bug where the metadata was not loading correctly in StoredFile.

Added more descriptive titles to Playlist UnitTests.

Added a test to get that the media file clip length is set/get correctly.
This commit is contained in:
paul.baranowski 2010-11-15 17:02:18 -05:00
parent 228aca224e
commit 31fd85a29f
3 changed files with 46 additions and 26 deletions

View File

@ -433,7 +433,7 @@ class StoredFile {
$this->gunid = StoredFile::generateGunid();
}
else {
$this->md = $this->loadMetadata();
$this->loadMetadata();
$this->exists = is_file($this->filepath) && is_readable($this->filepath);
}
}
@ -492,6 +492,7 @@ class StoredFile {
." WHERE gunid='$escapedValue'";
//var_dump($sql);
$this->md = $CC_DBC->getRow($sql);
//var_dump($this->md);
if (PEAR::isError($this->md)) {
$error = $this->md;
$this->md = null;
@ -508,7 +509,9 @@ class StoredFile {
$compatibilityData[$xmlName] = $value;
}
}
//var_dump($compatibilityData);
$this->md = array_merge($this->md, $compatibilityData);
//var_dump($this->md);
//$_SESSION["debug"] = $this->md;
}

View File

@ -42,22 +42,22 @@ class PlaylistTests extends PHPUnit_TestCase {
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("create");
$pl_id = $pl->create("Playlist UnitTest: create ".date("g:i a"));
if (!is_int($pl_id)) {
$this->fail("problems creating playlist.");
return;
@ -66,7 +66,7 @@ class PlaylistTests extends PHPUnit_TestCase {
function testGBLock() {
$pl = new Playlist();
$pl_id = $pl->create("lock test");
$pl_id = $pl->create("Playlist Metadata: lock ".date("g:i a"));
$sessid = Alib::Login('root', 'q');
@ -80,7 +80,7 @@ class PlaylistTests extends PHPUnit_TestCase {
function testGBUnLock() {
$pl = new Playlist();
$pl_id = $pl->create("unlock test");
$pl_id = $pl->create("Playlist UnitTest: unlock ".date("g:i a"));
$sessid = Alib::Login('root', 'q');
@ -92,12 +92,12 @@ class PlaylistTests extends PHPUnit_TestCase {
return;
}
}
function testGBSetPLMetaData() {
$pl = new Playlist();
$pl_id = $pl->create("set meta data test");
$pl_id = $pl->create("Playlist UnitTest: Set Metadata ".date("g:i a"));
$res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "A Title");
$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.");
@ -107,7 +107,7 @@ class PlaylistTests extends PHPUnit_TestCase {
function testGBGetPLMetaData() {
$pl = new Playlist();
$name = "Testing";
$name = "Playlist UnitTest: GetMetadata ".date("g:i a");
$pl_id = $pl->create($name);
$res = $this->greenbox->getPLMetadataValue($pl_id, "dc:title");
@ -121,12 +121,13 @@ class PlaylistTests extends PHPUnit_TestCase {
function testAddAudioClip() {
$pl = new Playlist();
$pl_id = $pl->create("Playlist Unit Test ". uniqid());
$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.");
@ -136,7 +137,7 @@ class PlaylistTests extends PHPUnit_TestCase {
function testMoveAudioClip() {
$pl = new Playlist();
$pl_id = $pl->create("Move");
$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());
@ -151,7 +152,7 @@ class PlaylistTests extends PHPUnit_TestCase {
function testDeleteAudioClip() {
$pl = new Playlist();
$pl_id = $pl->create("Delete");
$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);
@ -161,19 +162,19 @@ class PlaylistTests extends PHPUnit_TestCase {
return;
}
}
function testFadeInfo() {
$pl = new Playlist();
$pl_id = $pl->create("Fade Info");
$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;
}
return;
}
}
}

View File

@ -1,7 +1,5 @@
<?php
require_once(dirname(__FILE__).'/../StoredFile.php');
//require_once(dirname(__FILE__).'/../BasicStor.php');
//require_once(dirname(__FILE__).'/../GreenBox.php');
$dsn = $CC_CONFIG['dsn'];
$CC_DBC = DB::connect($dsn, TRUE);
@ -43,14 +41,16 @@ class StoredFileTest extends PHPUnit_TestCase {
$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();
}
$values = array("filepath" => $filePath);
// Insert and link to file, dont copy it
// 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());
@ -63,6 +63,7 @@ class StoredFileTest extends PHPUnit_TestCase {
return;
}
// Test loading metadata
$f = new StoredFile();
$f->__setGunid($storedFile->getGunid());
$f->loadMetadata();
@ -71,7 +72,22 @@ class StoredFileTest extends PHPUnit_TestCase {
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;
}
}
function testFoo() {
// Add a file
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
$this->storedFile = StoredFile::Insert($values, false);
}
}
?>