コード例 #1
0
 function test_getPlayableUrl()
 {
     $doc = $this->make_enclosure_audio(null, null);
     $this->assertNull(SDKWrapper::getPlayableUrl($doc));
     // valid file extension
     $doc = $this->make_enclosure_audio('http://foobar.gov/mp3.mp3');
     $this->assertEquals('http://foobar.gov/mp3.mp3', SDKWrapper::getPlayableUrl($doc));
     // invalid file extension
     $doc = $this->make_enclosure_audio('http://foobar.gov/mp3.jpg');
     $this->assertNull(SDKWrapper::getPlayableUrl($doc));
     // invalid extension, but valid type
     $doc = $this->make_enclosure_audio('http://foobar.gov/mp3.jpg', 'audio/mpeg');
     $this->assertEquals('http://foobar.gov/mp3.jpg', SDKWrapper::getPlayableUrl($doc));
     // invalid extension and type
     $doc = $this->make_enclosure_audio('http://foobar.gov/something', 'image/jpeg');
     $this->assertNull(SDKWrapper::getPlayableUrl($doc));
     // dereference m3u
     $doc = $this->make_enclosure_audio('http://api.npr.org/m3u/1450294957-2eb257.m3u');
     $this->assertRegexp('/\\.mp3$/', SDKWrapper::getPlayableUrl($doc));
 }