2019-04-21 16:30:02 +00:00
|
|
|
<?php
|
2019-10-03 19:24:12 +00:00
|
|
|
|
2019-04-21 16:30:02 +00:00
|
|
|
/**
|
|
|
|
* PlaylistArchiveStreamTest class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Alltube\Test;
|
|
|
|
|
2022-02-07 21:30:47 +00:00
|
|
|
use OndraM\CiDetector\CiDetector;
|
2019-04-21 16:30:02 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2021-10-17 19:01:55 +00:00
|
|
|
use PHPUnit\Util\Test;
|
2019-04-21 16:30:02 +00:00
|
|
|
|
|
|
|
/**
|
2019-04-22 14:05:58 +00:00
|
|
|
* Abstract class used by every test.
|
2019-04-21 16:30:02 +00:00
|
|
|
*/
|
|
|
|
abstract class BaseTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
2019-04-21 17:14:23 +00:00
|
|
|
* Get the config file used in tests.
|
|
|
|
*
|
|
|
|
* @return string Path to file
|
2019-04-21 16:30:02 +00:00
|
|
|
*/
|
2020-12-17 21:43:05 +00:00
|
|
|
protected function getConfigFile(): string
|
2019-04-21 16:30:02 +00:00
|
|
|
{
|
2020-06-22 21:22:42 +00:00
|
|
|
return __DIR__ . '/../config/config_test.yml';
|
2019-04-21 17:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare tests.
|
|
|
|
*/
|
2019-11-30 13:08:18 +00:00
|
|
|
protected function setUp(): void
|
2019-04-21 17:14:23 +00:00
|
|
|
{
|
2019-11-30 13:08:18 +00:00
|
|
|
$this->checkRequirements();
|
2019-04-21 16:30:02 +00:00
|
|
|
}
|
|
|
|
|
2019-10-26 14:13:08 +00:00
|
|
|
/**
|
|
|
|
* Check tests requirements.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function checkRequirements()
|
|
|
|
{
|
2022-02-07 21:30:47 +00:00
|
|
|
$ciDetector = new CiDetector();
|
2021-10-17 19:01:55 +00:00
|
|
|
$annotations = Test::parseTestMethodAnnotations(
|
|
|
|
static::class,
|
|
|
|
$this->getName()
|
|
|
|
);
|
2019-10-26 14:13:08 +00:00
|
|
|
$requires = [];
|
|
|
|
|
|
|
|
if (isset($annotations['class']['requires'])) {
|
2020-10-17 13:09:34 +00:00
|
|
|
$requires = array_merge($requires, $annotations['class']['requires']);
|
2019-10-26 14:13:08 +00:00
|
|
|
}
|
|
|
|
if (isset($annotations['method']['requires'])) {
|
2020-10-17 13:09:34 +00:00
|
|
|
$requires = array_merge($requires, $annotations['method']['requires']);
|
2019-10-26 14:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($requires as $require) {
|
2022-02-07 21:30:47 +00:00
|
|
|
if ($require == 'download' && $ciDetector->isCiDetected()) {
|
2019-10-26 14:13:08 +00:00
|
|
|
$this->markTestSkipped('Do not run tests that download videos on CI.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-21 16:30:02 +00:00
|
|
|
}
|