Просмотр исходного кода

:octocat: added phpunit constant to limit reader test maximum version

smiley 2 лет назад
Родитель
Сommit
cf4e5a7eaa
2 измененных файлов с 10 добавлено и 2 удалено
  1. 2 0
      phpunit.xml.dist
  2. 8 2
      tests/QRCodeReaderTestAbstract.php

+ 2 - 0
phpunit.xml.dist

@@ -33,5 +33,7 @@
 	<php>
 		<!-- whether the test runs on CI - set to false to allow debug output -->
 		<const name="TEST_IS_CI" value="true"/>
+		<!-- limit the maximum version for the reader test to speed up things -->
+		<const name="READER_TEST_MAX_VERSION" value="40"/>
 	</php>
 </phpunit>

+ 8 - 2
tests/QRCodeReaderTestAbstract.php

@@ -19,7 +19,7 @@ use chillerlan\QRCode\Output\QROutputInterface;
 use chillerlan\Settings\SettingsContainerInterface;
 use PHPUnit\Framework\TestCase;
 use Exception, Generator;
-use function array_map, sprintf, str_repeat, substr;
+use function array_map, defined, sprintf, str_repeat, substr;
 
 /**
  * Tests the QR Code reader
@@ -40,6 +40,11 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 	protected string                     $FQN;
 
 	protected function setUp():void{
+
+		if(!defined('READER_TEST_MAX_VERSION')){
+			$this::markTestSkipped('READER_TEST_MAX_VERSION not defined (see phpunit.xml.dist)');
+		}
+
 		$this->options = new QROptions;
 		$this->options->readerUseImagickIfAvailable = false;
 	}
@@ -117,7 +122,8 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 		$str       = str_repeat(self::loremipsum, 5);
 		$eccLevels = array_map(fn(int $ecc):EccLevel => new EccLevel($ecc), [EccLevel::L, EccLevel::M, EccLevel::Q, EccLevel::H]);
 
-		for($v = 1; $v <= 40; $v++){
+		/** @noinspection PhpUndefinedConstantInspection - see phpunit.xml.dist */
+		for($v = 1; $v <= READER_TEST_MAX_VERSION; $v++){
 			$version = new Version($v);
 
 			foreach($eccLevels as $eccLevel){