Lint
This commit is contained in:
parent
71d49ad74f
commit
bc695cfa15
15 changed files with 82 additions and 26 deletions
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Config;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +33,7 @@ abstract class BaseTest extends TestCase
|
|||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ class ConfigTest extends BaseTest
|
|||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ class ConfigTest extends BaseTest
|
|||
public function testGetInstance()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, false);
|
||||
$this->assertEquals(false, $config->convert);
|
||||
$this->assertConfig($config);
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,7 @@ class ConfigTest extends BaseTest
|
|||
Config::destroyInstance();
|
||||
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, false);
|
||||
$this->assertEquals(false, $config->convert);
|
||||
$this->assertConfig($config);
|
||||
}
|
||||
|
||||
|
@ -81,6 +82,7 @@ class ConfigTest extends BaseTest
|
|||
* Test the setFile function.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSetFile()
|
||||
{
|
||||
|
@ -103,24 +105,26 @@ class ConfigTest extends BaseTest
|
|||
* Test the setOptions function.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSetOptions()
|
||||
{
|
||||
Config::setOptions(['appName' => 'foo']);
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->appName, 'foo');
|
||||
$this->assertEquals('foo', $config->appName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the setOptions function.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSetOptionsWithoutUpdate()
|
||||
{
|
||||
Config::setOptions(['appName' => 'foo'], false);
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->appName, 'foo');
|
||||
$this->assertEquals('foo', $config->appName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +153,7 @@ class ConfigTest extends BaseTest
|
|||
* Test the getInstance function with the CONVERT and PYTHON environment variables.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetInstanceWithEnv()
|
||||
{
|
||||
|
@ -156,7 +161,7 @@ class ConfigTest extends BaseTest
|
|||
putenv('CONVERT=1');
|
||||
Config::setFile($this->getConfigFile());
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, true);
|
||||
$this->assertEquals(true, $config->convert);
|
||||
putenv('CONVERT');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use Alltube\Controller\DownloadController;
|
|||
use Alltube\Controller\FrontController;
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\ViewFactory;
|
||||
use Exception;
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
|
@ -48,6 +49,7 @@ abstract class ControllerTest extends BaseTest
|
|||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\ConvertedPlaylistArchiveStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the ConvertedPlaylistArchiveStream class.
|
||||
|
@ -17,6 +18,7 @@ class ConvertedPlaylistArchiveStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Config;
|
||||
use Alltube\Controller\DownloadController;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the FrontController class.
|
||||
|
@ -17,6 +18,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -62,6 +64,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with streams enabled.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithStream()
|
||||
{
|
||||
|
@ -77,6 +80,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with an M3U stream.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithM3uStream()
|
||||
{
|
||||
|
@ -96,6 +100,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with an RTMP stream.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithRtmpStream()
|
||||
{
|
||||
|
@ -113,6 +118,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with a remuxed video.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithRemux()
|
||||
{
|
||||
|
@ -182,6 +188,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires OS Linux
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithPlaylist()
|
||||
{
|
||||
|
@ -197,6 +204,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with an advanced conversion.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithAdvancedConversion()
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ class FrontControllerTest extends ControllerTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ class FrontControllerTest extends ControllerTest
|
|||
* Test the constructor with streams enabled.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testConstructorWithStream()
|
||||
{
|
||||
|
@ -120,6 +122,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithAudio()
|
||||
{
|
||||
|
@ -136,6 +139,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithVimeoAudio()
|
||||
{
|
||||
|
@ -150,6 +154,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithUnconvertedAudio()
|
||||
{
|
||||
|
@ -197,6 +202,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithStream()
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Controller\JsonController;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the FrontController class.
|
||||
|
@ -15,6 +16,7 @@ class JsonControllerTest extends ControllerTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Locale;
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\LocaleMiddleware;
|
||||
use Slim\Container;
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\PlaylistArchiveStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the PlaylistArchiveStream class.
|
||||
|
@ -17,6 +18,7 @@ class PlaylistArchiveStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ class VideoStubsTest extends BaseTest
|
|||
|
||||
/**
|
||||
* Initialize properties used by test.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Config;
|
||||
use Alltube\Exception\EmptyUrlException;
|
||||
use Alltube\Exception\PasswordException;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
|
@ -20,6 +22,7 @@ class VideoTest extends BaseTest
|
|||
* Test getExtractors function.
|
||||
*
|
||||
* @return void
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetExtractors()
|
||||
{
|
||||
|
@ -36,6 +39,8 @@ class VideoTest extends BaseTest
|
|||
* @param string $domain Domain
|
||||
*
|
||||
* @return void
|
||||
* @throws PasswordException
|
||||
* @throws EmptyUrlException
|
||||
* @dataProvider urlProvider
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @dataProvider remuxUrlProvider
|
||||
|
@ -57,6 +62,8 @@ class VideoTest extends BaseTest
|
|||
* Test getUrl function with a protected video.
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testgetUrlWithPassword()
|
||||
{
|
||||
|
@ -70,6 +77,8 @@ class VideoTest extends BaseTest
|
|||
* Test getUrl function with a protected video and no password.
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testgetUrlWithMissingPassword()
|
||||
{
|
||||
|
@ -82,6 +91,8 @@ class VideoTest extends BaseTest
|
|||
* Test getUrl function with a protected video and a wrong password.
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testgetUrlWithWrongPassword()
|
||||
{
|
||||
|
@ -96,6 +107,8 @@ class VideoTest extends BaseTest
|
|||
* @param string $url URL
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
* @dataProvider ErrorUrlProvider
|
||||
*/
|
||||
public function testgetUrlError($url)
|
||||
|
@ -112,7 +125,7 @@ class VideoTest extends BaseTest
|
|||
*/
|
||||
public function urlProvider()
|
||||
{
|
||||
$videos = [
|
||||
return [
|
||||
[
|
||||
'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'best[protocol^=http]',
|
||||
'It_s_Not_Me_It_s_You_-_Hearts_Under_Fire-M7IpKCZ47pU',
|
||||
|
@ -139,8 +152,6 @@ class VideoTest extends BaseTest
|
|||
'gcs-vimeo.akamaized.net',
|
||||
]
|
||||
];
|
||||
|
||||
return $videos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,7 +178,7 @@ class VideoTest extends BaseTest
|
|||
*/
|
||||
public function m3uUrlProvider()
|
||||
{
|
||||
$videos = [
|
||||
return [
|
||||
[
|
||||
'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176',
|
||||
'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576',
|
||||
|
@ -175,8 +186,6 @@ class VideoTest extends BaseTest
|
|||
'video.twimg.com',
|
||||
]
|
||||
];
|
||||
|
||||
return $videos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,6 +226,7 @@ class VideoTest extends BaseTest
|
|||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetJson($url, $format)
|
||||
{
|
||||
|
@ -237,6 +247,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider ErrorURLProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetJsonError($url)
|
||||
{
|
||||
|
@ -257,6 +268,7 @@ class VideoTest extends BaseTest
|
|||
* @dataProvider urlProvider
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @dataProvider remuxUrlProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetFilename($url, $format, $filename, $extension)
|
||||
{
|
||||
|
@ -271,6 +283,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider ErrorUrlProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetFilenameError($url)
|
||||
{
|
||||
|
@ -287,6 +300,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetAudioStream($url, $format)
|
||||
{
|
||||
|
@ -376,6 +390,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetM3uStream($url, $format)
|
||||
{
|
||||
|
@ -391,6 +406,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider remuxUrlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetRemuxStream($url, $format)
|
||||
{
|
||||
|
@ -422,6 +438,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider rtmpUrlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetRtmpStream($url, $format)
|
||||
{
|
||||
|
@ -458,6 +475,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetConvertedStream($url, $format)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ use Slim\Container;
|
|||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Views\Smarty;
|
||||
use SmartyException;
|
||||
|
||||
/**
|
||||
* Unit tests for the ViewFactory class.
|
||||
|
@ -22,6 +23,7 @@ class ViewFactoryTest extends BaseTest
|
|||
* Test the create() function.
|
||||
*
|
||||
* @return void
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
|
@ -35,6 +37,7 @@ class ViewFactoryTest extends BaseTest
|
|||
* Test the create() function with a X-Forwarded-Proto header.
|
||||
*
|
||||
* @return void
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function testCreateWithXForwardedProto()
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\YoutubeChunkStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
/**
|
||||
* Unit tests for the YoutubeChunkStream class.
|
||||
|
@ -17,6 +19,8 @@ class YoutubeChunkStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\YoutubeStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the YoutubeStream class.
|
||||
|
@ -17,6 +18,7 @@ class YoutubeStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use phpmock\mockery\PHPMockery;
|
|||
// Composer autoload.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
ini_set('session.use_cookies', 0);
|
||||
ini_set('session.use_cookies', '0');
|
||||
session_cache_limiter('');
|
||||
session_start();
|
||||
|
||||
|
|
Loading…
Reference in a new issue