function setup()
 {
     global $CC_CONFIG;
     $con = Propel::getConnection();
     // Clear the files table
     $sql = "DELETE FROM " . $CC_CONFIG["filesTable"];
     $con->exec($sql);
     // Add a file
     $values = array("filepath" => dirname(__FILE__) . "/test10001.mp3");
     $this->storedFile = Application_Model_StoredFile::Insert($values, false);
     // Add a file
     $values = array("filepath" => dirname(__FILE__) . "/test10002.mp3");
     $this->storedFile2 = Application_Model_StoredFile::Insert($values, false);
     // Clear the schedule table
     $sql = "DELETE FROM " . $CC_CONFIG["scheduleTable"];
     $con->exec($sql);
     // Create a playlist
     $playlist = new Application_Model_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 Application_Model_ScheduleGroup();
     $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
 }
Exemplo n.º 2
0
 function testAddAndRemovePlaylist()
 {
     // Create a playlist
     $playlist = new Application_Model_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 Application_Model_ScheduleGroup();
     $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
     $group = new Application_Model_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.");
     }
     Application_Model_Playlist::Delete($playlist->getId());
 }