From 6d9e5028fc37bdb1ecbdadfeb5b3c66ed4e0166f Mon Sep 17 00:00:00 2001 From: naomiaro Date: Tue, 21 Sep 2010 17:41:05 -0400 Subject: [PATCH] adding playlist tests --- .../htmlUI/var/templates/playlist/editor.tpl | 2 +- .../templates/popup/PLAYLIST.arrangeItems.tpl | 12 +- src/modules/storageServer/var/GreenBox.php | 2 +- src/modules/storageServer/var/Playlist.php | 8 +- .../storageServer/var/tests/PlayListTests.php | 138 ++++++++++++++++++ 5 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 src/modules/storageServer/var/tests/PlayListTests.php diff --git a/src/modules/htmlUI/var/templates/playlist/editor.tpl b/src/modules/htmlUI/var/templates/playlist/editor.tpl index 246dfee83..059934ddc 100644 --- a/src/modules/htmlUI/var/templates/playlist/editor.tpl +++ b/src/modules/htmlUI/var/templates/playlist/editor.tpl @@ -53,7 +53,7 @@ {$i.ftype|capitalize} - ##move up## + ##move up## ##move down## diff --git a/src/modules/htmlUI/var/templates/popup/PLAYLIST.arrangeItems.tpl b/src/modules/htmlUI/var/templates/popup/PLAYLIST.arrangeItems.tpl index f6e3702d3..ae4af6ede 100644 --- a/src/modules/htmlUI/var/templates/popup/PLAYLIST.arrangeItems.tpl +++ b/src/modules/htmlUI/var/templates/popup/PLAYLIST.arrangeItems.tpl @@ -25,7 +25,7 @@
- {foreach from=$PL->getFlat($PL->activeId) key='pos' item='i'} + {foreach from=$PL->getActiveArr($PL->activeId) key='pos' item='i'}
@@ -34,15 +34,15 @@ - {$i.title} - {assign var="_duration" value=$i.duration}{niceTime in=$_duration} - {$i.creator} - {$i.type|capitalize} + {$i.track_title} + {assign var="_duration" value=$i.cliplength}{niceTime in=$_duration} + {$i.artist_name} + {$i.ftype|capitalize} - +
{/foreach} diff --git a/src/modules/storageServer/var/GreenBox.php b/src/modules/storageServer/var/GreenBox.php index 6cd413f1f..386119c91 100644 --- a/src/modules/storageServer/var/GreenBox.php +++ b/src/modules/storageServer/var/GreenBox.php @@ -485,7 +485,7 @@ class GreenBox extends BasicStor { if($pl === FALSE) return FALSE; - $res = $pl->setMetaData($category, $value, $lang); + $res = $pl->setPLMetaData($category, $value, $lang); return $res; } diff --git a/src/modules/storageServer/var/Playlist.php b/src/modules/storageServer/var/Playlist.php index 7e2b919ca..6599ab17b 100644 --- a/src/modules/storageServer/var/Playlist.php +++ b/src/modules/storageServer/var/Playlist.php @@ -323,7 +323,7 @@ class Playlist { * @param int $p_subjid * Subject id (if sessid is not specified) * @return boolean - * previous state + * TRUE on success. */ public function setEditFlag($p_val=TRUE, $p_sessid=NULL, $p_subjid=NULL) { @@ -344,7 +344,7 @@ class Playlist { if (PEAR::isError($r)) { return $r; } - return ($state == 'edited'); + return TRUE; } /** @@ -584,7 +584,7 @@ class Playlist { return FALSE; $res = $this->addAudioClip($ac['file_id'], $newPos, $ac['fadein'], $ac['fadeOut'], $ac['cliplength'], $ac['cuein'], $ac['cueout']); - if($res !== TRUE) + if($res !== TRUE) return FALSE; return TRUE; @@ -701,7 +701,7 @@ class Playlist { return $res; } - public function setMetaData($category, $value) + public function setPLMetaData($category, $value) { global $CC_CONFIG, $CC_DBC; diff --git a/src/modules/storageServer/var/tests/PlayListTests.php b/src/modules/storageServer/var/tests/PlayListTests.php new file mode 100644 index 000000000..84baeda44 --- /dev/null +++ b/src/modules/storageServer/var/tests/PlayListTests.php @@ -0,0 +1,138 @@ +getMessage()." ".$CC_DBC->getUserInfo()."\n"; + exit(1); +} +$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); + +class PlayListTests extends PHPUnit_TestCase { + + private $greenbox; + + function __construct($name) { + parent::__construct($name); + } + + function setup() { + global $CC_CONFIG, $CC_DBC; + $this->greenbox = new GreenBox(); + + } + + function testGBCreatePlaylist() { + + $pl = new Playlist(); + $pl_id = $pl->create("create"); + + if (PEAR::isError($pl_id)) { + $this->fail("problems creating playlist."); + return; + } + } + + function testGBLock() { + $pl = new Playlist(); + $pl_id = $pl->create("lock test"); + + $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("unlock test"); + + $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("set meta data test"); + + $res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "A Title"); + + if($res !== TRUE) { + $this->fail("problems setting playlist metadata."); + return; + } + } + + function testGBGetPLMetaData() { + $pl = new Playlist(); + $name = "Testing"; + $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("Add"); + + $res = $this->greenbox->addAudioClipToPlaylist($pl_id, '1'); + + if($res !== TRUE) { + $this->fail("problems adding audioclip to playlist."); + return; + } + } + + function testMoveAudioClip() { + $pl = new Playlist(); + $pl_id = $pl->create("Move"); + + $this->greenbox->addAudioClipToPlaylist($pl_id, '1'); + $this->greenbox->addAudioClipToPlaylist($pl_id, '2'); + + $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("Delete"); + + $this->greenbox->addAudioClipToPlaylist($pl_id, '1'); + $res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0); + + if($res !== TRUE) { + $this->fail("problems deleting audioclip from playlist."); + return; + } + } + +} + +?> \ No newline at end of file