alltube/tests/BaseTest.php

63 lines
1.4 KiB
PHP
Raw Permalink Normal View History

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