Merge branch 'feature/travis' into develop

This commit is contained in:
Pierre Rudloff 2019-04-20 12:28:48 +02:00
commit 5cb8bc30b3
12 changed files with 631 additions and 237 deletions

View file

@ -2,16 +2,17 @@
install: install:
- sc config wuauserv start= auto - sc config wuauserv start= auto
- net start wuauserv - net start wuauserv
- cinst php composer ffmpeg phantomjs - cinst php --version 7.1.28
- cinst composer ffmpeg phantomjs
- refreshenv - refreshenv
- copy C:\tools\php72\php.ini-development C:\tools\php72\php.ini - copy C:\tools\php71\php.ini-development C:\tools\php71\php.ini
- echo extension=C:\tools\php72\ext\php_gmp.dll >> C:\tools\php72\php.ini - echo extension=C:\tools\php71\ext\php_gmp.dll >> C:\tools\php71\php.ini
- echo extension=C:\tools\php72\ext\php_gettext.dll >> C:\tools\php72\php.ini - echo extension=C:\tools\php71\ext\php_gettext.dll >> C:\tools\php71\php.ini
- echo extension=C:\tools\php72\ext\php_intl.dll >> C:\tools\php72\php.ini - echo extension=C:\tools\php71\ext\php_intl.dll >> C:\tools\php71\php.ini
- echo extension=C:\tools\php72\ext\php_openssl.dll >> C:\tools\php72\php.ini - echo extension=C:\tools\php71\ext\php_openssl.dll >> C:\tools\php71\php.ini
- echo extension=C:\tools\php72\ext\php_mbstring.dll >> C:\tools\php72\php.ini - echo extension=C:\tools\php71\ext\php_mbstring.dll >> C:\tools\php71\php.ini
- composer install --no-dev - composer install --no-dev
- composer global require phpunit/phpunit - composer global require phpunit/phpunit:^6.0
- C:\Python36\python.exe -m pip install youtube-dl - C:\Python36\python.exe -m pip install youtube-dl
test_script: test_script:

View file

@ -36,7 +36,8 @@ module.exports = function (grunt) {
phpstan: { phpstan: {
options: { options: {
level: 'max', level: 'max',
bin: 'vendor/bin/phpstan' bin: 'vendor/bin/phpstan',
config: 'phpstan.neon'
}, },
php: { php: {
src: ['*.php', 'classes/*.php', 'controllers/*.php'] src: ['*.php', 'classes/*.php', 'controllers/*.php']

View file

@ -66,8 +66,6 @@ class PlaylistArchiveStream extends TarArchive
*/ */
public function __construct(Config $config = null) public function __construct(Config $config = null)
{ {
parent::__construct();
$this->client = new Client(); $this->client = new Client();
$this->download = new VideoDownload($config); $this->download = new VideoDownload($config);
} }
@ -82,8 +80,11 @@ class PlaylistArchiveStream extends TarArchive
protected function send($data) protected function send($data)
{ {
$pos = ftell($this->buffer); $pos = ftell($this->buffer);
// Add data to the buffer.
fwrite($this->buffer, $data); fwrite($this->buffer, $data);
if ($pos !== false) { if ($pos !== false) {
// Rewind so that stream_read() can later read this data.
fseek($this->buffer, $pos); fseek($this->buffer, $pos);
} }
} }
@ -208,4 +209,16 @@ class PlaylistArchiveStream extends TarArchive
return fread($this->buffer, $count); return fread($this->buffer, $count);
} }
/**
* Called when fclose() is used on the stream.
*
* @return void
*/
public function stream_close()
{
if (is_resource($this->buffer)) {
fclose($this->buffer);
}
}
} }

View file

@ -722,14 +722,3 @@ h1 {
white-space: nowrap; white-space: nowrap;
width: 1px; width: 1px;
} }
.sr-only.focusable:active,
.sr-only.focusable:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
white-space: normal;
width: auto;
}

View file

@ -21,7 +21,7 @@
"grunt-markdownlint": "~2.1.0", "grunt-markdownlint": "~2.1.0",
"grunt-phpcs": "~0.4.0", "grunt-phpcs": "~0.4.0",
"grunt-phpdocumentor": "~0.4.1", "grunt-phpdocumentor": "~0.4.1",
"grunt-phpstan": "~0.1.0", "grunt-phpstan": "~0.2.0",
"grunt-phpunit": "~0.3.6" "grunt-phpunit": "~0.3.6"
}, },
"homepage": "https://www.alltubedownload.net/", "homepage": "https://www.alltubedownload.net/",

4
phpstan.neon Normal file
View file

@ -0,0 +1,4 @@
parameters:
ignoreErrors:
# The Archive constructor messes up the output buffering.
- '#Alltube\\PlaylistArchiveStream::__construct\(\) does not call parent constructor from Barracuda\\ArchiveStream\\TarArchive\.#'

View file

@ -292,6 +292,9 @@ class FrontControllerTest extends TestCase
*/ */
public function testVideoWithVimeoAudio() public function testVideoWithVimeoAudio()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
// So we can test the fallback to default format // So we can test the fallback to default format
$this->assertRequestIsOk('video', ['url' => 'https://vimeo.com/251997032', 'audio' => true]); $this->assertRequestIsOk('video', ['url' => 'https://vimeo.com/251997032', 'audio' => true]);
} }
@ -319,6 +322,9 @@ class FrontControllerTest extends TestCase
*/ */
public function testVideoWithPassword() public function testVideoWithPassword()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$result = $this->controller->video( $result = $this->controller->video(
$this->request->withQueryParams(['url' => 'http://vimeo.com/68375962']) $this->request->withQueryParams(['url' => 'http://vimeo.com/68375962'])
->withParsedBody(['password' => 'youtube-dl']), ->withParsedBody(['password' => 'youtube-dl']),
@ -334,6 +340,9 @@ class FrontControllerTest extends TestCase
*/ */
public function testVideoWithMissingPassword() public function testVideoWithMissingPassword()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$this->assertRequestIsOk('video', ['url' => 'http://vimeo.com/68375962']); $this->assertRequestIsOk('video', ['url' => 'http://vimeo.com/68375962']);
$this->assertRequestIsOk('video', ['url' => 'http://vimeo.com/68375962', 'audio' => true]); $this->assertRequestIsOk('video', ['url' => 'http://vimeo.com/68375962', 'audio' => true]);
} }
@ -433,6 +442,9 @@ class FrontControllerTest extends TestCase
*/ */
public function testRedirectWithM3uStream() public function testRedirectWithM3uStream()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Twitter returns a 429 error when the test is ran too many times.');
}
$this->config->stream = true; $this->config->stream = true;
$this->assertRequestIsOk( $this->assertRequestIsOk(
'redirect', 'redirect',
@ -502,6 +514,9 @@ class FrontControllerTest extends TestCase
*/ */
public function testRedirectWithMissingPassword() public function testRedirectWithMissingPassword()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$this->assertRequestIsRedirect('redirect', ['url' => 'http://vimeo.com/68375962']); $this->assertRequestIsRedirect('redirect', ['url' => 'http://vimeo.com/68375962']);
} }

View file

@ -26,19 +26,18 @@ class LocaleManagerTest extends TestCase
*/ */
protected function setUp() protected function setUp()
{ {
$this->localeManager = new LocaleManager();
$_SESSION[LocaleManager::class]['locale'] = 'foo_BAR'; $_SESSION[LocaleManager::class]['locale'] = 'foo_BAR';
$this->localeManager = new LocaleManager();
} }
/** /**
* Test the getSupportedLocales function. * Unset locale after each test.
* *
* @return void * @return void
*/ */
public function testConstructorWithCookies() protected function tearDown()
{ {
$localeManager = new LocaleManager([]); $this->localeManager->unsetLocale();
$this->assertEquals('foo_BAR', (string) $localeManager->getLocale());
} }
/** /**

View file

@ -77,4 +77,14 @@ class LocaleTest extends TestCase
{ {
$this->assertEquals('fr', $this->localeObject->getIso3166()); $this->assertEquals('fr', $this->localeObject->getIso3166());
} }
/**
* Test the getCountry function.
*
* @return void
*/
public function testGetCountry()
{
$this->assertEquals(country('fr'), $this->localeObject->getCountry());
}
} }

View file

@ -34,6 +34,16 @@ class PlaylistArchiveStreamTest extends TestCase
$this->stream = new PlaylistArchiveStream(Config::getInstance('config/'.$configFile)); $this->stream = new PlaylistArchiveStream(Config::getInstance('config/'.$configFile));
} }
/**
* Clean variables used in tests.
*
* @return void
*/
protected function tearDown()
{
$this->stream->stream_close();
}
/** /**
* Test the stream_open() function. * Test the stream_open() function.
* *

View file

@ -117,6 +117,9 @@ class VideoDownloadTest extends TestCase
*/ */
public function testGetURLWithPassword() public function testGetURLWithPassword()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$videoURL = $this->download->getURL('http://vimeo.com/68375962', null, 'youtube-dl'); $videoURL = $this->download->getURL('http://vimeo.com/68375962', null, 'youtube-dl');
$this->assertContains('vimeocdn.com', $videoURL[0]); $this->assertContains('vimeocdn.com', $videoURL[0]);
} }
@ -129,6 +132,9 @@ class VideoDownloadTest extends TestCase
*/ */
public function testGetURLWithMissingPassword() public function testGetURLWithMissingPassword()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$this->download->getURL('http://vimeo.com/68375962'); $this->download->getURL('http://vimeo.com/68375962');
} }
@ -140,6 +146,9 @@ class VideoDownloadTest extends TestCase
*/ */
public function testGetURLWithWrongPassword() public function testGetURLWithWrongPassword()
{ {
if (getenv('CI')) {
$this->markTestSkipped('Travis is blacklisted by Vimeo.');
}
$this->download->getURL('http://vimeo.com/68375962', null, 'foo'); $this->download->getURL('http://vimeo.com/68375962', null, 'foo');
} }
@ -164,7 +173,7 @@ class VideoDownloadTest extends TestCase
*/ */
public function urlProvider() public function urlProvider()
{ {
return [ $videos = [
[ [
'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'best[protocol^=http]', 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'best[protocol^=http]',
'It_s_Not_Me_It_s_You_-_Hearts_Under_Fire-M7IpKCZ47pU', 'It_s_Not_Me_It_s_You_-_Hearts_Under_Fire-M7IpKCZ47pU',
@ -178,12 +187,6 @@ class VideoDownloadTest extends TestCase
'mp4', 'mp4',
'googlevideo.com', 'googlevideo.com',
], ],
[
'https://vimeo.com/24195442', 'best[protocol^=http]',
'Carving_the_Mountains-24195442',
'mp4',
'vimeocdn.com',
],
[ [
'http://www.bbc.co.uk/programmes/b039g8p7', 'bestaudio/best', 'http://www.bbc.co.uk/programmes/b039g8p7', 'bestaudio/best',
'Kaleidoscope_Leonard_Cohen-b039d07m', 'Kaleidoscope_Leonard_Cohen-b039d07m',
@ -203,6 +206,18 @@ class VideoDownloadTest extends TestCase
'openload.co', '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;
} }
/** /**
@ -229,14 +244,19 @@ class VideoDownloadTest extends TestCase
*/ */
public function m3uUrlProvider() public function m3uUrlProvider()
{ {
return [ $videos = [];
[
if (!getenv('CI')) {
// Twitter returns a 429 error when the test is ran too many times.
$videos[] = [
'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176', 'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176',
'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576', 'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576',
'mp4', 'mp4',
'video.twimg.com', 'video.twimg.com',
], ];
]; }
return $videos;
} }
/** /**

728
yarn.lock

File diff suppressed because it is too large Load diff