From 43c49727f121a9bc0a7a4cf93097c3c63be56641 Mon Sep 17 00:00:00 2001 From: smiley Date: Thu, 9 Mar 2023 23:38:20 +0100 Subject: [PATCH] :shower: make data providers static (PHPUnit 10...) --- tests/Common/BitBufferTest.php | 2 +- tests/Common/MaskPatternTest.php | 2 +- tests/Common/ModeTest.php | 2 +- tests/Data/AlphaNumTest.php | 2 +- tests/Data/ByteTest.php | 2 +- tests/Data/DataInterfaceTestAbstract.php | 6 +++--- tests/Data/HanziTest.php | 4 ++-- tests/Data/KanjiTest.php | 4 ++-- tests/Data/NumberTest.php | 2 +- tests/Data/QRMatrixTest.php | 2 +- tests/QRCodeReaderImagickTest.php | 2 +- tests/QRCodeReaderTestAbstract.php | 8 ++++---- tests/QRMaxLengthTrait.php | 2 +- tests/QROptionsTest.php | 10 +++++----- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/Common/BitBufferTest.php b/tests/Common/BitBufferTest.php index 913ad60ec..b03f73424 100644 --- a/tests/Common/BitBufferTest.php +++ b/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], diff --git a/tests/Common/MaskPatternTest.php b/tests/Common/MaskPatternTest.php index 48dbfc2c7..a5ba6373a 100644 --- a/tests/Common/MaskPatternTest.php +++ b/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], diff --git a/tests/Common/ModeTest.php b/tests/Common/ModeTest.php index 1e6ec3bb0..4f82aa772 100644 --- a/tests/Common/ModeTest.php +++ b/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], diff --git a/tests/Data/AlphaNumTest.php b/tests/Data/AlphaNumTest.php index b05190990..aa3e6190d 100644 --- a/tests/Data/AlphaNumTest.php +++ b/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], diff --git a/tests/Data/ByteTest.php b/tests/Data/ByteTest.php index 214914717..3c78fbe83 100644 --- a/tests/Data/ByteTest.php +++ b/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! diff --git a/tests/Data/DataInterfaceTestAbstract.php b/tests/Data/DataInterfaceTestAbstract.php index b30d61716..8d1b07946 100644 --- a/tests/Data/DataInterfaceTestAbstract.php +++ b/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]]; } diff --git a/tests/Data/HanziTest.php b/tests/Data/HanziTest.php index 5aea5554f..a6211e546 100644 --- a/tests/Data/HanziTest.php +++ b/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++){ diff --git a/tests/Data/KanjiTest.php b/tests/Data/KanjiTest.php index 8dddb8b0e..8a664e20c 100644 --- a/tests/Data/KanjiTest.php +++ b/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); diff --git a/tests/Data/NumberTest.php b/tests/Data/NumberTest.php index 4799e24ce..5caf3e042 100644 --- a/tests/Data/NumberTest.php +++ b/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], diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index efffe813c..8209a4e62 100755 --- a/tests/Data/QRMatrixTest.php +++ b/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); diff --git a/tests/QRCodeReaderImagickTest.php b/tests/QRCodeReaderImagickTest.php index 0c623b289..4faea0a27 100644 --- a/tests/QRCodeReaderImagickTest.php +++ b/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'], diff --git a/tests/QRCodeReaderTestAbstract.php b/tests/QRCodeReaderTestAbstract.php index d79dedb88..fedc2b257 100644 --- a/tests/QRCodeReaderTestAbstract.php +++ b/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) ?? '') ]; } } diff --git a/tests/QRMaxLengthTrait.php b/tests/QRMaxLengthTrait.php index abdb43d68..517a0de7e 100644 --- a/tests/QRMaxLengthTrait.php +++ b/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, diff --git a/tests/QROptionsTest.php b/tests/QROptionsTest.php index afcf96849..b71c0f44d 100644 --- a/tests/QROptionsTest.php +++ b/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],