diff --git a/tests/BaseTest.php b/tests/BaseTest.php index 136a553..9a98f50 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -45,4 +45,29 @@ abstract class BaseTest extends TestCase { Config::destroyInstance(); } + + /** + * Check tests requirements. + * @return void + */ + protected function checkRequirements() + { + parent::checkRequirements(); + + $annotations = $this->getAnnotations(); + $requires = []; + + if (isset($annotations['class']['requires'])) { + $requires += $annotations['class']['requires']; + } + if (isset($annotations['method']['requires'])) { + $requires += $annotations['method']['requires']; + } + + foreach ($requires as $require) { + if ($require == 'download' && getenv('CI')) { + $this->markTestSkipped('Do not run tests that download videos on CI.'); + } + } + } } diff --git a/tests/ConvertedPlaylistArchiveStreamTest.php b/tests/ConvertedPlaylistArchiveStreamTest.php index 0c7b3c5..58b826e 100644 --- a/tests/ConvertedPlaylistArchiveStreamTest.php +++ b/tests/ConvertedPlaylistArchiveStreamTest.php @@ -11,6 +11,7 @@ use Alltube\Video; /** * Unit tests for the ConvertedPlaylistArchiveStream class. + * @requires download */ class ConvertedPlaylistArchiveStreamTest extends StreamTest { diff --git a/tests/DownloadControllerTest.php b/tests/DownloadControllerTest.php index ada74f7..7bc4d93 100644 --- a/tests/DownloadControllerTest.php +++ b/tests/DownloadControllerTest.php @@ -11,6 +11,7 @@ use Alltube\Controller\DownloadController; /** * Unit tests for the FrontController class. + * @requires download */ class DownloadControllerTest extends ControllerTest { @@ -79,10 +80,6 @@ class DownloadControllerTest extends ControllerTest */ public function testDownloadWithM3uStream() { - if (getenv('CI')) { - $this->markTestSkipped('Twitter returns a 429 error when the test is ran too many times.'); - } - Config::setOptions(['stream' => true]); $this->assertRequestIsOk( @@ -153,9 +150,6 @@ class DownloadControllerTest extends ControllerTest */ public function testDownloadWithMissingPassword() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } $this->assertRequestIsRedirect('download', ['url' => 'http://vimeo.com/68375962']); } diff --git a/tests/FrontControllerTest.php b/tests/FrontControllerTest.php index 0d9248b..2904d47 100644 --- a/tests/FrontControllerTest.php +++ b/tests/FrontControllerTest.php @@ -108,6 +108,7 @@ class FrontControllerTest extends ControllerTest * Test the info() function. * * @return void + * @requires download */ public function testInfo() { @@ -118,6 +119,7 @@ class FrontControllerTest extends ControllerTest * Test the info() function with audio conversion. * * @return void + * @requires download */ public function testInfoWithAudio() { @@ -133,12 +135,10 @@ class FrontControllerTest extends ControllerTest * Test the info() function with audio conversion from a Vimeo video. * * @return void + * @requires download */ public function testInfoWithVimeoAudio() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } Config::setOptions(['convert' => true]); // So we can test the fallback to default format @@ -149,6 +149,7 @@ class FrontControllerTest extends ControllerTest * Test the info() function with audio enabled and an URL that doesn't need to be converted. * * @return void + * @requires download */ public function testInfoWithUnconvertedAudio() { @@ -167,12 +168,10 @@ class FrontControllerTest extends ControllerTest * Test the info() function with a password. * * @return void + * @requires download */ public function testInfoWithPassword() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } $result = $this->controller->info( $this->request->withQueryParams(['url' => 'http://vimeo.com/68375962']) ->withParsedBody(['password' => 'youtube-dl']), @@ -185,12 +184,10 @@ class FrontControllerTest extends ControllerTest * Test the info() function with a missing password. * * @return void + * @requires download */ public function testInfoWithMissingPassword() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } $this->assertRequestIsOk('info', ['url' => 'http://vimeo.com/68375962']); $this->assertRequestIsOk('info', ['url' => 'http://vimeo.com/68375962', 'audio' => true]); } @@ -199,6 +196,7 @@ class FrontControllerTest extends ControllerTest * Test the info() function with streams enabled. * * @return void + * @requires download */ public function testInfoWithStream() { @@ -215,6 +213,7 @@ class FrontControllerTest extends ControllerTest * Test the info() function with a playlist. * * @return void + * @requires download */ public function testInfoWithPlaylist() { diff --git a/tests/JsonControllerTest.php b/tests/JsonControllerTest.php index 3b5de08..d25f3e6 100644 --- a/tests/JsonControllerTest.php +++ b/tests/JsonControllerTest.php @@ -27,6 +27,7 @@ class JsonControllerTest extends ControllerTest * Test the json() function. * * @return void + * @requires download */ public function testJson() { @@ -37,6 +38,7 @@ class JsonControllerTest extends ControllerTest * Test the json() function with an error. * * @return void + * @requires download */ public function testJsonWithError() { diff --git a/tests/PlaylistArchiveStreamTest.php b/tests/PlaylistArchiveStreamTest.php index afefcb2..9c301a3 100644 --- a/tests/PlaylistArchiveStreamTest.php +++ b/tests/PlaylistArchiveStreamTest.php @@ -11,6 +11,7 @@ use Alltube\Video; /** * Unit tests for the PlaylistArchiveStream class. + * @requires download */ class PlaylistArchiveStreamTest extends StreamTest { diff --git a/tests/VideoTest.php b/tests/VideoTest.php index 913538b..b19b538 100644 --- a/tests/VideoTest.php +++ b/tests/VideoTest.php @@ -11,6 +11,7 @@ use Alltube\Video; /** * Unit tests for the Video class. + * @requires download */ class VideoTest extends BaseTest { @@ -58,10 +59,6 @@ class VideoTest extends BaseTest */ public function testgetUrlWithPassword() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } - $video = new Video('http://vimeo.com/68375962', 'best', 'youtube-dl'); foreach ($video->getUrl() as $videoURL) { $this->assertContains('vimeocdn.com', $videoURL); @@ -76,10 +73,6 @@ class VideoTest extends BaseTest */ public function testgetUrlWithMissingPassword() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } - $video = new Video('http://vimeo.com/68375962'); $video->getUrl(); } @@ -92,10 +85,6 @@ class VideoTest extends BaseTest */ public function testgetUrlWithWrongPassword() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } - $video = new Video('http://vimeo.com/68375962', 'best', 'foo'); $video->getUrl(); } @@ -148,17 +137,13 @@ class VideoTest extends BaseTest 'mp4', 'openload.co', ], - ]; - - if (!getenv('CI')) { - // Travis is blacklisted by Vimeo. - $videos[] = [ + [ 'https://vimeo.com/24195442', 'best[protocol^=http]', 'Carving_the_Mountains-24195442', 'mp4', 'vimeocdn.com', - ]; - } + ] + ]; return $videos; } @@ -187,17 +172,14 @@ class VideoTest extends BaseTest */ public function m3uUrlProvider() { - $videos = []; - - if (!getenv('CI')) { - // Twitter returns a 429 error when the test is ran too many times. - $videos[] = [ + $videos = [ + [ 'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176', 'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576', 'mp4', 'video.twimg.com', - ]; - } + ] + ]; return $videos; } @@ -359,10 +341,6 @@ class VideoTest extends BaseTest */ public function testGetAudioStreamDashError() { - if (getenv('CI')) { - $this->markTestSkipped('Travis is blacklisted by Vimeo.'); - } - $video = new Video('https://vimeo.com/251997032', 'bestaudio/best'); $video->getAudioStream(); } diff --git a/tests/YoutubeChunkStreamTest.php b/tests/YoutubeChunkStreamTest.php index cae27c0..a817119 100644 --- a/tests/YoutubeChunkStreamTest.php +++ b/tests/YoutubeChunkStreamTest.php @@ -11,6 +11,7 @@ use Alltube\Video; /** * Unit tests for the YoutubeChunkStream class. + * @requires download */ class YoutubeChunkStreamTest extends StreamTest { diff --git a/tests/YoutubeStreamTest.php b/tests/YoutubeStreamTest.php index f855aa8..3bbd325 100644 --- a/tests/YoutubeStreamTest.php +++ b/tests/YoutubeStreamTest.php @@ -11,6 +11,7 @@ use Alltube\Video; /** * Unit tests for the YoutubeStream class. + * @requires download */ class YoutubeStreamTest extends StreamTest {