diff --git a/backend/StoredFile.php b/backend/StoredFile.php index 37c380528..a1c65dcd1 100644 --- a/backend/StoredFile.php +++ b/backend/StoredFile.php @@ -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; } diff --git a/backend/tests/PlaylistTests.php b/backend/tests/PlaylistTests.php index 9899c6df4..bd8bc95bf 100644 --- a/backend/tests/PlaylistTests.php +++ b/backend/tests/PlaylistTests.php @@ -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; + } } } diff --git a/backend/tests/StoredFileTests.php b/backend/tests/StoredFileTests.php index 322b94aab..d5fea7ee3 100644 --- a/backend/tests/StoredFileTests.php +++ b/backend/tests/StoredFileTests.php @@ -1,7 +1,5 @@ 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); + + } } ?> \ No newline at end of file