public function testInvalidURLs() { $urls = [null, 'invalid-url', __FILE__]; $analyzer = new VideoServiceUrlAnalyzer(); foreach ($urls as $url) { $this->assertNull($analyzer->analyze($url)); } }
public function testVimeo() { $urls = ['https://vimeo.com/137221490', 'https://vimeo.com/channels/staffpicks/137221490', 'https://player.vimeo.com/video/137221490']; $analyzer = new VideoServiceUrlAnalyzer(); foreach ($urls as $url) { $video = $analyzer->analyze($url); $this->assertInstanceOf('TakaakiMizuno\\VideoServiceUrlAnalyzer\\Entities\\Vimeo', $video, "{$url} is not detected"); $this->assertEquals('Vimeo', $video->getServiceName()); $this->assertEquals('137221490', $video->getId()); $this->assertEquals('https://vimeo.com/137221490', $video->getUrl()); $this->assertNotEmpty($video->getTitle()); $this->assertNotEmpty($video->getThumbnailUrl()); $this->assertGreaterThan(0, $video->getDuration()); $this->assertGreaterThan(0, $video->getWidth()); $this->assertGreaterThan(0, $video->getHeight()); $this->assertGreaterThan(0, $video->getThumbnailWidth()); $this->assertGreaterThan(0, $video->getThumbnailHeight()); } }