diff --git a/src/QRCode.php b/src/QRCode.php index 6dd654c72..9101969c8 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -221,6 +221,9 @@ class QRCode{ /** * checks if a string qualifies as numeric (convenience method) + * + * @deprecated + * @codeCoverageIgnore */ public function isNumber(string $string):bool{ return Number::validateString($string); @@ -228,6 +231,9 @@ class QRCode{ /** * checks if a string qualifies as alphanumeric (convenience method) + * + * @deprecated + * @codeCoverageIgnore */ public function isAlphaNum(string $string):bool{ return AlphaNum::validateString($string); @@ -235,6 +241,9 @@ class QRCode{ /** * checks if a string qualifies as Kanji (convenience method) + * + * @deprecated + * @codeCoverageIgnore */ public function isKanji(string $string):bool{ return Kanji::validateString($string); @@ -242,6 +251,9 @@ class QRCode{ /** * a dummy (convenience method) + * + * @deprecated + * @codeCoverageIgnore */ public function isByte(string $string):bool{ return Byte::validateString($string); diff --git a/tests/Data/AlphaNumTest.php b/tests/Data/AlphaNumTest.php index c5a105911..444190ea0 100644 --- a/tests/Data/AlphaNumTest.php +++ b/tests/Data/AlphaNumTest.php @@ -20,4 +20,14 @@ final class AlphaNumTest extends DatainterfaceTestAbstract{ protected string $FQN = AlphaNum::class; protected string $testdata = '0 $%*+-./:'; + /** + * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase) + */ + public function stringValidateProvider():array{ + return [ + ['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true], + ['abc', false], + ]; + } + } diff --git a/tests/Data/ByteTest.php b/tests/Data/ByteTest.php index 90d80699c..5b6e336c2 100644 --- a/tests/Data/ByteTest.php +++ b/tests/Data/ByteTest.php @@ -20,11 +20,22 @@ final class ByteTest extends DatainterfaceTestAbstract{ protected string $FQN = Byte::class; protected string $testdata = '[¯\_(ツ)_/¯]'; + /** + * isByte() passses any binary string and only fails on empty strings + */ + public function stringValidateProvider():array{ + return [ + ["\x01\x02\x03", true], + [' ', true], // not empty! + ['', false], + ]; + } + /** * @inheritDoc */ public function testInvalidDataException():void{ - $this->markTestSkipped('N/A'); + $this::markTestSkipped('N/A'); } } diff --git a/tests/Data/DatainterfaceTestAbstract.php b/tests/Data/DatainterfaceTestAbstract.php index 2cf9422ec..184849ce1 100644 --- a/tests/Data/DatainterfaceTestAbstract.php +++ b/tests/Data/DatainterfaceTestAbstract.php @@ -75,6 +75,16 @@ abstract class DatainterfaceTestAbstract extends TestCase{ $this::assertSame(1, $getMinimumVersion->invoke($this->QRData)); } + abstract public function stringValidateProvider():array; + + /** + * @dataProvider stringValidateProvider + */ + public function testValidateString(string $string, bool $expected):void{ + /** @noinspection PhpUndefinedMethodInspection */ + $this::assertSame($expected, $this->FQN::validateString($string)); + } + /** * Tests if an exception is thrown when the data exceeds the maximum version while auto detecting */ diff --git a/tests/Data/KanjiTest.php b/tests/Data/KanjiTest.php index e277d83a3..fc89851d0 100644 --- a/tests/Data/KanjiTest.php +++ b/tests/Data/KanjiTest.php @@ -20,4 +20,16 @@ final class KanjiTest extends DatainterfaceTestAbstract{ protected string $FQN = Kanji::class; protected string $testdata = '茗荷茗荷茗荷茗荷茗荷'; + /** + * isKanji() should pass on Kanji/SJIS characters and fail on everything else + */ + public function stringValidateProvider():array{ + return [ + ['茗荷', true], + ['Ã', false], + ['ABC', false], + ['123', false], + ]; + } + } diff --git a/tests/Data/NumberTest.php b/tests/Data/NumberTest.php index dcc40b093..73a398df5 100644 --- a/tests/Data/NumberTest.php +++ b/tests/Data/NumberTest.php @@ -20,4 +20,14 @@ final class NumberTest extends DatainterfaceTestAbstract{ protected string $FQN = Number::class; protected string $testdata = '0123456789'; + /** + * isNumber() should pass on any number and fail on anything else + */ + public function stringValidateProvider():array{ + return [ + ['0123456789', true], + ['ABC123', false], + ]; + } + } diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index d458e86b2..4396f212f 100755 --- a/tests/Data/QRMatrixTest.php +++ b/tests/Data/QRMatrixTest.php @@ -146,7 +146,7 @@ final class QRMatrixTest extends TestCase{ public function testSetAlignmentPattern(int $version):void{ if($version === 1){ - $this->markTestSkipped('N/A (Version 1 has no alignment pattern)'); + $this::markTestSkipped('N/A (Version 1 has no alignment pattern)'); } $matrix = $this @@ -208,7 +208,7 @@ final class QRMatrixTest extends TestCase{ public function testSetVersionNumber(int $version):void{ if($version < 7){ - $this->markTestSkipped('N/A (Version < 7)'); + $this::markTestSkipped('N/A (Version < 7)'); } $matrix = $this->getMatrix($version)->setVersionNumber(); diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index 8db4f012d..0580baa56 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -31,45 +31,6 @@ final class QRCodeTest extends TestCase{ $this->options = new QROptions; } - /** - * isNumber() should pass on any number and fail on anything else - */ - public function testIsNumber():void{ - $this::assertTrue($this->qrcode->isNumber('0123456789')); - - $this::assertFalse($this->qrcode->isNumber('ABC123')); - } - - /** - * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase) - */ - public function testIsAlphaNum():void{ - $this::assertTrue($this->qrcode->isAlphaNum('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:')); - - $this::assertFalse($this->qrcode->isAlphaNum('abc')); - } - - /** - * isKanji() should pass on Kanji/SJIS characters and fail on everything else - */ - public function testIsKanji():void{ - $this::assertTrue($this->qrcode->isKanji('茗荷')); - - $this::assertFalse($this->qrcode->isKanji('Ã')); - $this::assertFalse($this->qrcode->isKanji('ABC')); - $this::assertFalse($this->qrcode->isKanji('123')); - } - - /** - * isByte() passses any binary string and only fails on empty strings - */ - public function testIsByte():void{ - $this::assertTrue($this->qrcode->isByte("\x01\x02\x03")); - $this::assertTrue($this->qrcode->isByte(' ')); // not empty! - - $this::assertFalse($this->qrcode->isByte('')); - } - /** * tests if an exception is thrown when an invalid (built-in) output type is specified */