File tree Expand file tree Collapse file tree 8 files changed +68
-42
lines changed Expand file tree Collapse file tree 8 files changed +68
-42
lines changed Original file line number Diff line number Diff line change @@ -221,27 +221,39 @@ protected function initCustomOutputInterface():QROutputInterface{
221
221
222
222
/**
223
223
* checks if a string qualifies as numeric (convenience method)
224
+ *
225
+ * @deprecated
226
+ * @codeCoverageIgnore
224
227
*/
225
228
public function isNumber (string $ string ):bool {
226
229
return Number::validateString ($ string );
227
230
}
228
231
229
232
/**
230
233
* checks if a string qualifies as alphanumeric (convenience method)
234
+ *
235
+ * @deprecated
236
+ * @codeCoverageIgnore
231
237
*/
232
238
public function isAlphaNum (string $ string ):bool {
233
239
return AlphaNum::validateString ($ string );
234
240
}
235
241
236
242
/**
237
243
* checks if a string qualifies as Kanji (convenience method)
244
+ *
245
+ * @deprecated
246
+ * @codeCoverageIgnore
238
247
*/
239
248
public function isKanji (string $ string ):bool {
240
249
return Kanji::validateString ($ string );
241
250
}
242
251
243
252
/**
244
253
* a dummy (convenience method)
254
+ *
255
+ * @deprecated
256
+ * @codeCoverageIgnore
245
257
*/
246
258
public function isByte (string $ string ):bool {
247
259
return Byte::validateString ($ string );
Original file line number Diff line number Diff line change @@ -20,4 +20,14 @@ final class AlphaNumTest extends DatainterfaceTestAbstract{
20
20
protected string $ FQN = AlphaNum::class;
21
21
protected string $ testdata = '0 $%*+-./: ' ;
22
22
23
+ /**
24
+ * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase)
25
+ */
26
+ public function stringValidateProvider ():array {
27
+ return [
28
+ ['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./: ' , true ],
29
+ ['abc ' , false ],
30
+ ];
31
+ }
32
+
23
33
}
Original file line number Diff line number Diff line change @@ -20,11 +20,22 @@ final class ByteTest extends DatainterfaceTestAbstract{
20
20
protected string $ FQN = Byte::class;
21
21
protected string $ testdata = '[¯\_(ツ)_/¯] ' ;
22
22
23
+ /**
24
+ * isByte() passses any binary string and only fails on empty strings
25
+ */
26
+ public function stringValidateProvider ():array {
27
+ return [
28
+ ["\x01\x02\x03" , true ],
29
+ [' ' , true ], // not empty!
30
+ ['' , false ],
31
+ ];
32
+ }
33
+
23
34
/**
24
35
* @inheritDoc
25
36
*/
26
37
public function testInvalidDataException ():void {
27
- $ this -> markTestSkipped ('N/A ' );
38
+ $ this :: markTestSkipped ('N/A ' );
28
39
}
29
40
30
41
}
Original file line number Diff line number Diff line change @@ -75,6 +75,16 @@ public function testGetMinimumVersion():void{
75
75
$ this ::assertSame (1 , $ getMinimumVersion ->invoke ($ this ->QRData ));
76
76
}
77
77
78
+ abstract public function stringValidateProvider ():array ;
79
+
80
+ /**
81
+ * @dataProvider stringValidateProvider
82
+ */
83
+ public function testValidateString (string $ string , bool $ expected ):void {
84
+ /** @noinspection PhpUndefinedMethodInspection */
85
+ $ this ::assertSame ($ expected , $ this ->FQN ::validateString ($ string ));
86
+ }
87
+
78
88
/**
79
89
* Tests if an exception is thrown when the data exceeds the maximum version while auto detecting
80
90
*/
Original file line number Diff line number Diff line change @@ -20,4 +20,16 @@ final class KanjiTest extends DatainterfaceTestAbstract{
20
20
protected string $ FQN = Kanji::class;
21
21
protected string $ testdata = '茗荷茗荷茗荷茗荷茗荷 ' ;
22
22
23
+ /**
24
+ * isKanji() should pass on Kanji/SJIS characters and fail on everything else
25
+ */
26
+ public function stringValidateProvider ():array {
27
+ return [
28
+ ['茗荷 ' , true ],
29
+ ['Ã ' , false ],
30
+ ['ABC ' , false ],
31
+ ['123 ' , false ],
32
+ ];
33
+ }
34
+
23
35
}
Original file line number Diff line number Diff line change @@ -20,4 +20,14 @@ final class NumberTest extends DatainterfaceTestAbstract{
20
20
protected string $ FQN = Number::class;
21
21
protected string $ testdata = '0123456789 ' ;
22
22
23
+ /**
24
+ * isNumber() should pass on any number and fail on anything else
25
+ */
26
+ public function stringValidateProvider ():array {
27
+ return [
28
+ ['0123456789 ' , true ],
29
+ ['ABC123 ' , false ],
30
+ ];
31
+ }
32
+
23
33
}
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ public function testSetSeparators(int $version):void{
146
146
public function testSetAlignmentPattern (int $ version ):void {
147
147
148
148
if ($ version === 1 ){
149
- $ this -> markTestSkipped ('N/A (Version 1 has no alignment pattern) ' );
149
+ $ this :: markTestSkipped ('N/A (Version 1 has no alignment pattern) ' );
150
150
}
151
151
152
152
$ matrix = $ this
@@ -208,7 +208,7 @@ public function testSetTimingPattern(int $version):void{
208
208
public function testSetVersionNumber (int $ version ):void {
209
209
210
210
if ($ version < 7 ){
211
- $ this -> markTestSkipped ('N/A (Version < 7) ' );
211
+ $ this :: markTestSkipped ('N/A (Version < 7) ' );
212
212
}
213
213
214
214
$ matrix = $ this ->getMatrix ($ version )->setVersionNumber ();
Original file line number Diff line number Diff line change @@ -31,45 +31,6 @@ protected function setUp():void{
31
31
$ this ->options = new QROptions ;
32
32
}
33
33
34
- /**
35
- * isNumber() should pass on any number and fail on anything else
36
- */
37
- public function testIsNumber ():void {
38
- $ this ::assertTrue ($ this ->qrcode ->isNumber ('0123456789 ' ));
39
-
40
- $ this ::assertFalse ($ this ->qrcode ->isNumber ('ABC123 ' ));
41
- }
42
-
43
- /**
44
- * isAlphaNum() should pass on the 45 defined characters and fail on anything else (e.g. lowercase)
45
- */
46
- public function testIsAlphaNum ():void {
47
- $ this ::assertTrue ($ this ->qrcode ->isAlphaNum ('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./: ' ));
48
-
49
- $ this ::assertFalse ($ this ->qrcode ->isAlphaNum ('abc ' ));
50
- }
51
-
52
- /**
53
- * isKanji() should pass on Kanji/SJIS characters and fail on everything else
54
- */
55
- public function testIsKanji ():void {
56
- $ this ::assertTrue ($ this ->qrcode ->isKanji ('茗荷 ' ));
57
-
58
- $ this ::assertFalse ($ this ->qrcode ->isKanji ('Ã ' ));
59
- $ this ::assertFalse ($ this ->qrcode ->isKanji ('ABC ' ));
60
- $ this ::assertFalse ($ this ->qrcode ->isKanji ('123 ' ));
61
- }
62
-
63
- /**
64
- * isByte() passses any binary string and only fails on empty strings
65
- */
66
- public function testIsByte ():void {
67
- $ this ::assertTrue ($ this ->qrcode ->isByte ("\x01\x02\x03" ));
68
- $ this ::assertTrue ($ this ->qrcode ->isByte (' ' )); // not empty!
69
-
70
- $ this ::assertFalse ($ this ->qrcode ->isByte ('' ));
71
- }
72
-
73
34
/**
74
35
* tests if an exception is thrown when an invalid (built-in) output type is specified
75
36
*/
You can’t perform that action at this time.
0 commit comments