2019-04-21 18:30:02 +02:00
|
|
|
<?php
|
2019-10-03 21:24:12 +02:00
|
|
|
|
2019-04-21 18:30:02 +02:00
|
|
|
/**
|
|
|
|
* PlaylistArchiveStreamTest class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Alltube\Test;
|
|
|
|
|
|
|
|
use Alltube\Config;
|
2020-06-21 01:44:20 +02:00
|
|
|
use Alltube\Exception\ConfigException;
|
2019-04-21 18:30:02 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
2019-04-22 16:05:58 +02:00
|
|
|
* Abstract class used by every test.
|
2019-04-21 18:30:02 +02:00
|
|
|
*/
|
|
|
|
abstract class BaseTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
2019-04-21 19:14:23 +02:00
|
|
|
* Get the config file used in tests.
|
|
|
|
*
|
|
|
|
* @return string Path to file
|
2019-04-21 18:30:02 +02:00
|
|
|
*/
|
2019-04-21 19:14:23 +02:00
|
|
|
protected function getConfigFile()
|
2019-04-21 18:30:02 +02:00
|
|
|
{
|
2020-06-22 23:22:42 +02:00
|
|
|
return __DIR__ . '/../config/config_test.yml';
|
2019-04-21 19:14:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare tests.
|
2020-06-21 01:44:20 +02:00
|
|
|
* @throws ConfigException
|
2019-04-21 19:14:23 +02:00
|
|
|
*/
|
2019-11-30 14:08:18 +01:00
|
|
|
protected function setUp(): void
|
2019-04-21 19:14:23 +02:00
|
|
|
{
|
|
|
|
Config::setFile($this->getConfigFile());
|
2019-11-30 14:08:18 +01:00
|
|
|
$this->checkRequirements();
|
2019-04-21 18:30:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy properties after test.
|
|
|
|
*/
|
2019-11-30 14:08:18 +01:00
|
|
|
protected function tearDown(): void
|
2019-04-21 18:30:02 +02:00
|
|
|
{
|
|
|
|
Config::destroyInstance();
|
|
|
|
}
|
2019-10-26 16:13:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check tests requirements.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function checkRequirements()
|
|
|
|
{
|
|
|
|
$annotations = $this->getAnnotations();
|
|
|
|
$requires = [];
|
|
|
|
|
|
|
|
if (isset($annotations['class']['requires'])) {
|
2020-10-17 15:09:34 +02:00
|
|
|
$requires = array_merge($requires, $annotations['class']['requires']);
|
2019-10-26 16:13:08 +02:00
|
|
|
}
|
|
|
|
if (isset($annotations['method']['requires'])) {
|
2020-10-17 15:09:34 +02:00
|
|
|
$requires = array_merge($requires, $annotations['method']['requires']);
|
2019-10-26 16:13:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($requires as $require) {
|
|
|
|
if ($require == 'download' && getenv('CI')) {
|
|
|
|
$this->markTestSkipped('Do not run tests that download videos on CI.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-21 18:30:02 +02:00
|
|
|
}
|