コード例 #1
0
 public function testGetTracksWithTag()
 {
     $mm = new MultimediaObject();
     $t1 = new Track();
     $t1->setTags(array('master'));
     $t2 = new Track();
     $t2->setTags(array('mosca', 'master', 'old'));
     $t3 = new Track();
     $t3->setTags(array('master', 'mosca'));
     $t4 = new Track();
     $t4->setTags(array('flv', 'itunes', 'hide'));
     $t5 = new Track();
     $t5->setTags(array('flv', 'webtv'));
     $mm->addTrack($t3);
     $mm->addTrack($t2);
     $mm->addTrack($t1);
     $mm->addTrack($t4);
     $mm->addTrack($t5);
     $this->assertEquals(array($t3, $t2, $t1), $mm->getTracksWithTag('master'));
     $this->assertEquals($t3, $mm->getTrackWithTag('master'));
     $this->assertEquals(null, $mm->getTrackWithTag('del_universo'));
     $this->assertEquals($t3, $mm->getTrackWithAnyTag(array('master', 'pr')));
     $this->assertEquals(array($t2), $mm->getTracksWithAllTags(array('master', 'mosca', 'old')));
     $this->assertTrue(in_array($mm->getTrackWithAllTags(array('mosca', 'master')), array($t3, $t2)));
     $this->assertEquals(null, $mm->getTrackWithAllTags(array('mosca', 'master', 'del_universo')));
     $this->assertEquals(4, count($mm->getTracksWithAnyTag(array('master', 'webtv'))));
     $this->assertEquals(1, count($mm->getTrackWithAnyTag(array('master'))));
     $this->assertEquals(null, $mm->getTrackWithAnyTag(array('del_universo')));
     $this->assertEquals(5, count($mm->getFilteredTracksWithTags()));
     $this->assertEquals(3, count($mm->getFilteredTracksWithTags(array('master'))));
     $this->assertEquals(1, count($mm->getFilteredTracksWithTags(array('master'), array('mosca', 'old'))));
     $this->assertEquals(0, count($mm->getFilteredTracksWithTags(array(), array('mosca', 'old'), array('master'))));
     $this->assertEquals(3, count($mm->getFilteredTracksWithTags(array(), array(), array('flv'))));
     $this->assertEquals(0, count($mm->getFilteredTracksWithTags(array(), array(), array('flv', 'master'))));
     $this->assertEquals(5, count($mm->getFilteredTracksWithTags(array(), array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mm->getFilteredTracksWithTags(array('mosca', 'old'), array(), array(), array('old'))));
     $this->assertEquals(1, count($mm->getFilteredTrackWithTags()));
     $this->assertEquals(1, count($mm->getFilteredTrackWithTags(array('master'))));
     $this->assertEquals(1, count($mm->getFilteredTrackWithTags(array('master'), array('mosca', 'old'))));
     $this->assertEquals(0, count($mm->getFilteredTrackWithTags(array(), array('mosca', 'old'), array('master'))));
     $this->assertEquals(1, count($mm->getFilteredTrackWithTags(array(), array(), array('flv'))));
     $this->assertEquals(0, count($mm->getFilteredTrackWithTags(array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mm->getFilteredTrackWithTags(array(), array(), array(), array('flv', 'master'))));
     $this->assertEquals(1, count($mm->getFilteredTrackWithTags(array('mosca', 'old'), array(), array(), array('old'))));
 }