Skip to content

Commit 2478f75

Browse files
committed
🔥 v6.0 second pass: PHPUnit 10.4
1 parent 39e3dfe commit 2478f75

20 files changed

+87
-123
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"require-dev": {
4848
"chillerlan/php-authenticator": "^5.0",
4949
"phan/phan": "^5.4",
50-
"phpunit/phpunit": "^9.6",
50+
"phpunit/phpunit": "^10.4",
5151
"phpmd/phpmd": "^2.14",
5252
"setasign/fpdf": "^1.8.2",
5353
"squizlabs/php_codesniffer": "^3.7"

phpunit.xml.dist

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<?xml version="1.0"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".build/phpunit.result.cache"
6-
colors="true"
7-
verbose="true"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".build/phpunit-cache"
6+
colors="true"
87
>
98
<testsuites>
109
<testsuite name="php-qrcode test suite">
11-
<directory suffix=".php">./tests/</directory>
10+
<directory>./tests/</directory>
1211
<exclude>./tests/Performance</exclude>
1312
</testsuite>
1413
</testsuites>
15-
<coverage processUncoveredFiles="true">
14+
<source>
1615
<include>
17-
<directory suffix=".php">./src</directory>
16+
<directory>src</directory>
1817
</include>
18+
</source>
19+
<coverage>
1920
<report>
2021
<clover outputFile=".build/coverage/clover.xml"/>
2122
<xml outputDirectory=".build/coverage/coverage-xml"/>

tests/Common/BitBufferTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use chillerlan\QRCode\Common\{BitBuffer, Mode};
1414
use chillerlan\QRCode\QRCodeException;
15+
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\TestCase;
1617

1718
/**
@@ -34,9 +35,7 @@ public static function bitProvider():array{
3435
];
3536
}
3637

37-
/**
38-
* @dataProvider bitProvider
39-
*/
38+
#[DataProvider('bitProvider')]
4039
public function testPut(int $data, int $value):void{
4140
$this->bitBuffer->put($data, 4);
4241
$this::assertSame($value, $this->bitBuffer->getBuffer()[0]);

tests/Common/ECICharsetTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use chillerlan\QRCode\Common\ECICharset;
1414
use chillerlan\QRCode\QRCodeException;
15+
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\TestCase;
1617

1718
final class ECICharsetTest extends TestCase{
@@ -20,17 +21,15 @@ public static function invalidIdProvider():array{
2021
return [[-1], [1000000]];
2122
}
2223

23-
/**
24-
* @dataProvider invalidIdProvider
25-
*/
24+
#[DataProvider('invalidIdProvider')]
2625
public function testInvalidDataException(int $id):void{
2726
$this->expectException(QRCodeException::class);
2827
$this->expectExceptionMessage('invalid charset id:');
2928
/** @phan-suppress-next-line PhanNoopNew */
3029
new ECICharset($id);
3130
}
3231

33-
public function encodingProvider():array{
32+
public static function encodingProvider():array{
3433
$params = [];
3534

3635
foreach(ECICharset::MB_ENCODINGS as $id => $name){
@@ -40,9 +39,7 @@ public function encodingProvider():array{
4039
return $params;
4140
}
4241

43-
/**
44-
* @dataProvider encodingProvider
45-
*/
42+
#[DataProvider('encodingProvider')]
4643
public function testGetName(int $id, string $name = null):void{
4744
$eciCharset = new ECICharset($id);
4845

tests/Common/MaskPatternTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use chillerlan\QRCode\Common\MaskPattern;
1717
use chillerlan\QRCode\QRCodeException;
1818
use Closure;
19+
use PHPUnit\Framework\Attributes\DataProvider;
1920
use PHPUnit\Framework\TestCase;
2021

2122
/**
@@ -95,9 +96,8 @@ public static function maskPatternProvider():array{
9596

9697
/**
9798
* Tests if the mask function generates the correct pattern
98-
*
99-
* @dataProvider maskPatternProvider
10099
*/
100+
#[DataProvider('maskPatternProvider')]
101101
public function testMask(int $pattern, array $expected):void{
102102
$maskPattern = new MaskPattern($pattern);
103103

tests/Common/ModeTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use chillerlan\QRCode\Common\Mode;
1414
use chillerlan\QRCode\QRCodeException;
15+
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\TestCase;
1617

1718
/**
@@ -33,9 +34,7 @@ public static function versionProvider():array{
3334
];
3435
}
3536

36-
/**
37-
* @dataProvider versionProvider
38-
*/
37+
#[DataProvider('versionProvider')]
3938
public function testGetLengthBitsForVersionBreakpoints(int $version, int $expected):void{
4039
$this::assertSame($expected, Mode::getLengthBitsForVersion(Mode::NUMBER, $version));
4140
}

tests/Data/ByteTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ public static function stringValidateProvider():array{
3636
* @inheritDoc
3737
*/
3838
public function testInvalidDataException():void{
39-
/** @noinspection PhpUnitTestFailedLineInspection */
4039
$this::markTestSkipped('N/A (binary mode)');
4140
}
4241

4342
/**
4443
* @inheritDoc
4544
*/
4645
public function testBinaryStringInvalid():void{
47-
/** @noinspection PhpUnitTestFailedLineInspection */
4846
$this::markTestSkipped('N/A (binary mode)');
4947
}
5048

tests/Data/DataInterfaceTestAbstract.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace chillerlan\QRCodeTest\Data;
1212

1313
use chillerlan\QRCode\Common\{EccLevel, MaskPattern, Mode, Version};
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use chillerlan\QRCode\Data\{QRCodeDataException, QRData, QRDataModeInterface, QRMatrix};
1516
use chillerlan\QRCode\QROptions;
1617
use chillerlan\QRCodeTest\QRMaxLengthTrait;
@@ -64,9 +65,8 @@ public static function maskPatternProvider():array{
6465

6566
/**
6667
* Tests initializing the data matrix
67-
*
68-
* @dataProvider maskPatternProvider
6968
*/
69+
#[DataProvider('maskPatternProvider')]
7070
public function testInitMatrix(int $pattern):void{
7171
$maskPattern = new MaskPattern($pattern);
7272

@@ -82,9 +82,8 @@ abstract public static function stringValidateProvider():array;
8282

8383
/**
8484
* Tests if a string is properly validated for the respective data mode
85-
*
86-
* @dataProvider stringValidateProvider
8785
*/
86+
#[DataProvider('stringValidateProvider')]
8887
public function testValidateString(string $string, bool $expected):void{
8988
/** @noinspection PhpUndefinedMethodInspection */
9089
$this::assertSame($expected, static::$FQN::validateString($string));
@@ -109,9 +108,8 @@ public static function versionBreakpointProvider():array{
109108

110109
/**
111110
* Tests decoding a data segment from a given BitBuffer
112-
*
113-
* @dataProvider versionBreakpointProvider
114111
*/
112+
#[DataProvider('versionBreakpointProvider')]
115113
public function testDecodeSegment(int $version):void{
116114
$options = new QROptions;
117115
$options->version = $version;
@@ -168,9 +166,7 @@ public static function maxLengthProvider():Generator{
168166

169167
}
170168

171-
/**
172-
* @dataProvider maxLengthProvider
173-
*/
169+
#[DataProvider('maxLengthProvider')]
174170
public function testMaxLength(Version $version, EccLevel $eccLevel, string $str):void{
175171
$options = new QROptions;
176172
$options->version = $version->getVersionNumber();
@@ -185,9 +181,8 @@ public function testMaxLength(Version $version, EccLevel $eccLevel, string $str)
185181

186182
/**
187183
* Tests getting the minimum QR version for the given data
188-
*
189-
* @dataProvider maxLengthProvider
190184
*/
185+
#[DataProvider('maxLengthProvider')]
191186
public function testGetMinimumVersion(Version $version, EccLevel $eccLevel, string $str):void{
192187
$options = new QROptions;
193188
$options->version = Version::AUTO;
@@ -208,9 +203,8 @@ public function testGetMinimumVersion(Version $version, EccLevel $eccLevel, stri
208203

209204
/**
210205
* Tests if an exception is thrown on data overflow
211-
*
212-
* @dataProvider maxLengthProvider
213206
*/
207+
#[DataProvider('maxLengthProvider')]
214208
public function testMaxLengthOverflowException(Version $version, EccLevel $eccLevel, string $str, string $str1):void{
215209
$this->expectException(QRCodeDataException::class);
216210
$this->expectExceptionMessage('code length overflow');

tests/Data/ECITest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use chillerlan\QRCode\QROptions;
1414
use chillerlan\QRCode\Common\{BitBuffer, ECICharset, Mode};
1515
use chillerlan\QRCode\Data\{Byte, ECI, Number, QRCodeDataException, QRData, QRDataModeInterface};
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\TestCase;
1718

1819
/**
@@ -51,8 +52,8 @@ public static function versionBreakpointProvider():array{
5152

5253
/**
5354
* @inheritDoc
54-
* @dataProvider versionBreakpointProvider
5555
*/
56+
#[DataProvider('versionBreakpointProvider')]
5657
public function testDecodeSegment(int $version):void{
5758
$options = new QROptions;
5859
$options->version = $version;
@@ -102,9 +103,7 @@ public static function eciCharsetIdProvider():array{
102103
];
103104
}
104105

105-
/**
106-
* @dataProvider eciCharsetIdProvider
107-
*/
106+
#[DataProvider('eciCharsetIdProvider')]
108107
public function testReadWrite(int $id, int $lengthInBits):void{
109108
$bitBuffer = new BitBuffer;
110109
$eci = (new ECI($id))->write($bitBuffer, 1);
@@ -133,7 +132,7 @@ public function testDecodeECISegmentFollowedByInvalidModeException():void{
133132
ECI::decodeSegment($bitBuffer, $options->version);
134133
}
135134

136-
public function unknownEncodingDataProvider():array{
135+
public static function unknownEncodingDataProvider():array{
137136
return [
138137
'CP437' => [0, "\x41\x42\x43"],
139138
'ISO_IEC_8859_1_GLI' => [1, "\x41\x42\x43"],
@@ -142,9 +141,8 @@ public function unknownEncodingDataProvider():array{
142141

143142
/**
144143
* Tests detection of an unknown character set
145-
*
146-
* @dataProvider unknownEncodingDataProvider
147144
*/
145+
#[DataProvider('unknownEncodingDataProvider')]
148146
public function testConvertUnknownEncoding(int $id, string $data):void{
149147
$options = new QROptions;
150148
$options->version = 5;

tests/Data/HanziTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
use chillerlan\QRCode\Data\Hanzi;
1414
use Generator, Throwable;
15+
use PHPUnit\Framework\Attributes\DataProvider;
16+
use PHPUnit\Framework\Attributes\Group;
1517
use function bin2hex, chr, defined, sprintf;
1618

1719
/**
@@ -57,10 +59,8 @@ public static function hanziProvider():Generator{
5759

5860
}
5961

60-
/**
61-
* @group slow
62-
* @dataProvider hanziProvider
63-
*/
62+
#[Group('slow')]
63+
#[DataProvider('hanziProvider')]
6464
public function testValidateGB2312(string $chr):void{
6565
// we may run into several issues due to encoding detection failures
6666
try{

0 commit comments

Comments
 (0)