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

:shower: make data providers static (PHPUnit 10...)

smiley 2 лет назад
Родитель
Сommit
43c49727f1

+ 1 - 1
tests/Common/BitBufferTest.php

@@ -25,7 +25,7 @@ final class BitBufferTest extends TestCase{
 		$this->bitBuffer = new BitBuffer;
 	}
 
-	public function bitProvider():array{
+	public static function bitProvider():array{
 		return [
 			'number'   => [Mode::NUMBER, 16],
 			'alphanum' => [Mode::ALPHANUM, 32],

+ 1 - 1
tests/Common/MaskPatternTest.php

@@ -22,7 +22,7 @@ use PHPUnit\Framework\TestCase;
 final class MaskPatternTest extends TestCase{
 
 	// See mask patterns on the page 43 of JISX0510:2004.
-	public function maskPatternProvider():array{
+	public static function maskPatternProvider():array{
 		return [
 			'PATTERN_000' => [MaskPattern::PATTERN_000, [
 				[1, 0, 1, 0, 1, 0],

+ 1 - 1
tests/Common/ModeTest.php

@@ -22,7 +22,7 @@ final class ModeTest extends TestCase{
 	/**
 	 * version breakpoints for numeric mode
 	 */
-	public function versionProvider():array{
+	public static function versionProvider():array{
 		return [
 			[ 1, 10],
 			[ 9, 10],

+ 1 - 1
tests/Data/AlphaNumTest.php

@@ -23,7 +23,7 @@ final class AlphaNumTest extends DataInterfaceTestAbstract{
 	/**
 	 * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase)
 	 */
-	public function stringValidateProvider():array{
+	public static function stringValidateProvider():array{
 		return [
 			['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true],
 			['abc', false],

+ 1 - 1
tests/Data/ByteTest.php

@@ -23,7 +23,7 @@ final class ByteTest extends DataInterfaceTestAbstract{
 	/**
 	 * isByte() passses any binary string and only fails on empty strings
 	 */
-	public function stringValidateProvider():array{
+	public static function stringValidateProvider():array{
 		return [
 			["\x01\x02\x03", true],
 			['            ', true], // not empty!

+ 3 - 3
tests/Data/DataInterfaceTestAbstract.php

@@ -52,7 +52,7 @@ abstract class DataInterfaceTestAbstract extends TestCase{
 	 * @see testInitMatrix()
 	 * @return int[][]
 	 */
-	public function maskPatternProvider():array{
+	public static function maskPatternProvider():array{
 		return [[0], [1], [2], [3], [4], [5], [6], [7]];
 	}
 
@@ -86,7 +86,7 @@ abstract class DataInterfaceTestAbstract extends TestCase{
 		$this::assertSame(1, $version->getVersionNumber());
 	}
 
-	abstract public function stringValidateProvider():array;
+	abstract public static function stringValidateProvider():array;
 
 	/**
 	 * Tests if a string is properly validated for the respective data mode
@@ -111,7 +111,7 @@ abstract class DataInterfaceTestAbstract extends TestCase{
 	/**
 	 * returns versions within the version breakpoints 1-9, 10-26 and 27-40
 	 */
-	public function versionBreakpointProvider():array{
+	public static function versionBreakpointProvider():array{
 		return ['1-9' => [7], '10-26' => [15], '27-40' => [30]];
 	}
 

+ 2 - 2
tests/Data/HanziTest.php

@@ -25,7 +25,7 @@ class HanziTest extends DataInterfaceTestAbstract{
 	/**
 	 * isGB2312() should pass on Hanzi/GB2312 characters and fail on everything else
 	 */
-	public function stringValidateProvider():array{
+	public static function stringValidateProvider():array{
 		return [
 			['原神', true],
 			['ABC', false],
@@ -39,7 +39,7 @@ class HanziTest extends DataInterfaceTestAbstract{
 	/**
 	 * lists all characters in the valid GB2312 range
 	 */
-	public function hanziProvider():Generator{
+	public static function hanziProvider():Generator{
 
 		for($byte1 = 0xa1; $byte1 < 0xf8; $byte1++){
 

+ 2 - 2
tests/Data/KanjiTest.php

@@ -25,7 +25,7 @@ final class KanjiTest extends DataInterfaceTestAbstract{
 	/**
 	 * isKanji() should pass on Kanji/SJIS characters and fail on everything else
 	 */
-	public function stringValidateProvider():array{
+	public static function stringValidateProvider():array{
 		return [
 			['茗荷', true],
 			['Ã', false], // this will fail in SJIS-2004
@@ -39,7 +39,7 @@ final class KanjiTest extends DataInterfaceTestAbstract{
 	/**
 	 * lists the valid SJIS kanji
 	 */
-	public function kanjiProvider():Generator{
+	public static function kanjiProvider():Generator{
 		$key = fn(int $byte1, int $byte2):string => sprintf('0x%X', ($byte1 << 8 | $byte2));
 		$val = fn(int $byte1, int $byte2):string => mb_convert_encoding(chr($byte1).chr($byte2), 'UTF-8', Kanji::ENCODING);
 

+ 1 - 1
tests/Data/NumberTest.php

@@ -23,7 +23,7 @@ final class NumberTest extends DataInterfaceTestAbstract{
 	/**
 	 * isNumber() should pass on any number and fail on anything else
 	 */
-	public function stringValidateProvider():array{
+	public static function stringValidateProvider():array{
 		return [
 			['0123456789', true],
 			['ABC123', false],

+ 1 - 1
tests/Data/QRMatrixTest.php

@@ -167,7 +167,7 @@ final class QRMatrixTest extends TestCase{
 	/**
 	 * Version data provider for several pattern tests
 	 */
-	public function matrixProvider():Generator{
+	public static function matrixProvider():Generator{
 		$ecc  = new EccLevel(EccLevel::L);
 		$mask = new MaskPattern(MaskPattern::PATTERN_000);
 

+ 1 - 1
tests/QRCodeReaderImagickTest.php

@@ -33,7 +33,7 @@ final class QRCodeReaderImagickTest extends QRCodeReaderTestAbstract{
 		$this->options->readerUseImagickIfAvailable = true;
 	}
 
-	public function vectorQRCodeProvider():array{
+	public static function vectorQRCodeProvider():array{
 		return [
 			// SVG convert only works on windows (Warning: Option --export-png= is deprecated)
 			'SVG' => ['vector_sample.svg', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'],

+ 4 - 4
tests/QRCodeReaderTestAbstract.php

@@ -44,7 +44,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 		$this->options->readerUseImagickIfAvailable = false;
 	}
 
-	public function qrCodeProvider():array{
+	public static function qrCodeProvider():array{
 		return [
 			'helloworld' => ['hello_world.png', 'Hello world!', false],
 			// covers mirroring
@@ -112,8 +112,8 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 		$this::assertSame($numeric.$alphanum.$kanji.$hanzi.$byte, $result->data);
 	}
 
-	public function dataTestProvider():Generator{
-		$str       = str_repeat($this::loremipsum, 5);
+	public static function dataTestProvider():Generator{
+		$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++){
@@ -123,7 +123,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 				yield 'version: '.$version.$eccLevel => [
 					$version,
 					$eccLevel,
-					substr($str, 0, $this->getMaxLengthForMode(Mode::BYTE, $version, $eccLevel) ?? '')
+					substr($str, 0, self::getMaxLengthForMode(Mode::BYTE, $version, $eccLevel) ?? '')
 				];
 			}
 		}

+ 1 - 1
tests/QRMaxLengthTrait.php

@@ -78,7 +78,7 @@ trait QRMaxLengthTrait{
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 * @codeCoverageIgnore
 	 */
-	public function getMaxLengthForMode(int $mode, Version $version, EccLevel $eccLevel):?int{
+	public static function getMaxLengthForMode(int $mode, Version $version, EccLevel $eccLevel):?int{
 
 		$dataModes = [
 			Mode::NUMBER   => 0,

+ 5 - 5
tests/QROptionsTest.php

@@ -24,7 +24,7 @@ final class QROptionsTest extends TestCase{
 	/**
 	 * @return int[][]
 	 */
-	public function VersionProvider():array{
+	public static function VersionProvider():array{
 		return [
 			'values > 40 should be clamped to 40'        => [42, 40],
 			'values < 1 should be clamped to 1'          => [-42, 1],
@@ -47,7 +47,7 @@ final class QROptionsTest extends TestCase{
 	/**
 	 * @return int[][]
 	 */
-	public function VersionMinMaxProvider():array{
+	public static function VersionMinMaxProvider():array{
 		return [
 			'normal clamp'         => [5, 10, 5, 10],
 			'exceeding values'     => [-42, 42, 1, 40],
@@ -71,7 +71,7 @@ final class QROptionsTest extends TestCase{
 	/**
 	 * @return int[][][]
 	 */
-	public function RGBProvider():array{
+	public static function RGBProvider():array{
 		return [
 			'exceeding values' => [[-1, 0, 999], [0, 0 ,255]],
 			'too few values'   => [[1, 2], [255, 255, 255]],
@@ -103,7 +103,7 @@ final class QROptionsTest extends TestCase{
 	/**
 	 * @return int[][]
 	 */
-	public function logoSpaceValueProvider():array{
+	public static function logoSpaceValueProvider():array{
 		return [
 			'negative' => [ -1,   0],
 			'zero'     => [  0,   0],
@@ -150,7 +150,7 @@ final class QROptionsTest extends TestCase{
 	/**
 	 * @return float[][]
 	 */
-	public function circleRadiusProvider():array{
+	public static function circleRadiusProvider():array{
 		return [
 			[0.0, 0.1],
 			[0.5, 0.5],