More robust way to detect CI in tests

This commit is contained in:
Pierre Rudloff 2022-02-07 22:30:47 +01:00
parent fe771886d9
commit 18847e4d75

View file

@ -6,6 +6,7 @@
namespace Alltube\Test; namespace Alltube\Test;
use OndraM\CiDetector\CiDetector;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Test; use PHPUnit\Util\Test;
@ -38,6 +39,7 @@ abstract class BaseTest extends TestCase
*/ */
protected function checkRequirements() protected function checkRequirements()
{ {
$ciDetector = new CiDetector();
$annotations = Test::parseTestMethodAnnotations( $annotations = Test::parseTestMethodAnnotations(
static::class, static::class,
$this->getName() $this->getName()
@ -52,7 +54,7 @@ abstract class BaseTest extends TestCase
} }
foreach ($requires as $require) { foreach ($requires as $require) {
if ($require == 'download' && getenv('CI')) { if ($require == 'download' && $ciDetector->isCiDetected()) {
$this->markTestSkipped('Do not run tests that download videos on CI.'); $this->markTestSkipped('Do not run tests that download videos on CI.');
} }
} }