Skip to content

Commit 7823738

Browse files
authored
Bump PHPUnit (#71)
* Bump PHPUnit * wip
1 parent 759689f commit 7823738

File tree

9 files changed

+41
-17
lines changed

9 files changed

+41
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ vendor
55
.phpunit.result.cache
66
composer.lock
77
node_modules
8+
.phpunit.cache

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
}
99
],
1010
"scripts": {
11-
"test:e2e": "vendor/bin/phpunit tests",
12-
"test:unit": "vendor/bin/phpunit src",
13-
"test": ["@test:unit", "@test:e2e"],
14-
"test:update-snapshots": "vendor/bin/phpunit tests -d --update-snapshots",
11+
"test": "XDEBUG_MODE=coverage vendor/bin/phpunit",
12+
"test:no-coverage": "vendor/bin/phpunit",
13+
"test:update-snapshots": "vendor/bin/phpunit -d --update-snapshots",
1514
"cs:src": "vendor/bin/php-cs-fixer fix src",
1615
"cs:tests": "vendor/bin/php-cs-fixer fix tests",
1716
"cs": ["@cs:src", "@cs:tests"],
@@ -44,8 +43,8 @@
4443
"bin/php-converter-ts"
4544
],
4645
"require-dev": {
47-
"phpunit/phpunit": "^9",
48-
"spatie/phpunit-snapshot-assertions": "4.2.8",
46+
"phpunit/phpunit": "^10",
47+
"spatie/phpunit-snapshot-assertions": "^5",
4948
"myclabs/php-enum": "^1.8",
5049
"friendsofphp/php-cs-fixer": "^3.0",
5150
"symfony/var-dumper": "^5.3|^6.0",

phpunit.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache" beStrictAboutCoverageMetadata="true">
3+
<testsuites>
4+
<testsuite name="default">
5+
<directory>tests</directory>
6+
<directory>src</directory>
7+
</testsuite>
8+
</testsuites>
9+
<coverage>
10+
<report>
11+
<text outputFile="php://stdout" showUncoveredFiles="true"/>
12+
</report>
13+
</coverage>
14+
<source>
15+
<include>
16+
<directory suffix=".php">src</directory>
17+
</include>
18+
</source>
19+
</phpunit>

src/Ast/PhpDocTypeParser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function __construct()
3535

3636
public function parse(string $input): PhpTypeInterface|null
3737
{
38-
$result = $this->phpDocParser->parse(new TokenIterator($this->lexer->tokenize($input)))->children;
38+
$tokens = new TokenIterator($this->lexer->tokenize($input));
39+
$result = $this->phpDocParser->parse($tokens)->children;
3940
if (!is_array($result)) {
4041
return null;
4142
}

src/Ast/PhpDocTypeParserTest.php

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

55
namespace Riverwaysoft\PhpConverter\Ast;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use PHPUnit\Framework\TestCase;
89
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpBaseType;
910
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpListType;
@@ -14,7 +15,7 @@
1415

1516
class PhpDocTypeParserTest extends TestCase
1617
{
17-
/** @dataProvider getData */
18+
#[DataProvider('getData')]
1819
public function testBasicScenario(string $explanation, string $input, PhpTypeInterface|null $expected): void
1920
{
2021
$parser = new PhpDocTypeParser();
@@ -23,7 +24,7 @@ public function testBasicScenario(string $explanation, string $input, PhpTypeInt
2324
}
2425

2526
/** @return array{string, string, PhpTypeInterface|null}[] */
26-
public function getData(): array
27+
public static function getData(): array
2728
{
2829
return [
2930
[

src/Dto/DtoTypeTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
namespace Riverwaysoft\PhpConverter\Dto;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use PHPUnit\Framework\TestCase;
67
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpBaseType;
78

89
class DtoTypeTest extends TestCase
910
{
10-
/** @dataProvider provideEmptyDto */
11+
#[DataProvider('provideEmptyDto')]
1112
public function testIsEmpty(DtoType $dto, bool $isEmptyExpected): void
1213
{
1314
$this->assertEquals($isEmptyExpected, $dto->isEmpty());
1415
}
1516

16-
/** @dataProvider provideStringEnumDto */
17+
#[DataProvider('provideStringEnumDto')]
1718
public function testIsStringEnum(DtoType $dto, bool $isStringExpected): void
1819
{
1920
$this->assertEquals($isStringExpected, $dto->isStringEnum());
2021
}
2122

2223
/** @return \Generator<array{0: DtoType, 1: bool}> */
23-
public function provideEmptyDto(): iterable
24+
public static function provideEmptyDto(): iterable
2425
{
2526
yield [new DtoType(
2627
name: 'User',
@@ -53,7 +54,7 @@ public function provideEmptyDto(): iterable
5354
}
5455

5556
/** @return \Generator<array{0: DtoType, 1: bool}> */
56-
public function provideStringEnumDto(): iterable
57+
public static function provideStringEnumDto(): iterable
5758
{
5859
yield [new DtoType(
5960
name: 'RoleEnum',

src/Language/Dart/DartEnumValidatorTest.php

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

33
namespace Riverwaysoft\PhpConverter\Language\Dart;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use PHPUnit\Framework\TestCase;
67
use Riverwaysoft\PhpConverter\Dto\DtoEnumProperty;
78
use Riverwaysoft\PhpConverter\Dto\DtoType;
@@ -36,7 +37,7 @@ public function testValidationForDart(): void
3637
$this->expectNotToPerformAssertions();
3738
}
3839

39-
/** @dataProvider provideInvalidData */
40+
#[DataProvider('provideInvalidData')]
4041
public function testInvalidEnumForDart(DtoType $enumInvalid, string $message): void
4142
{
4243
if (PHP_VERSION_ID < 80100) {
@@ -50,7 +51,7 @@ public function testInvalidEnumForDart(DtoType $enumInvalid, string $message): v
5051
$dartEnumValidator->assertIsValidEnumForDart($enumInvalid);
5152
}
5253

53-
public function provideInvalidData(): \Generator
54+
public static function provideInvalidData(): \Generator
5455
{
5556
yield [
5657
new DtoType(

tests/ConverterTest.php

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

55
namespace App\Tests;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use PHPUnit\Framework\TestCase;
89
use Riverwaysoft\PhpConverter\Ast\Converter;
910
use Riverwaysoft\PhpConverter\Ast\DtoVisitor;
@@ -273,7 +274,7 @@ public function getUserMethodsString() {}
273274
$this->assertMatchesJsonSnapshot(json_encode($result->apiEndpointList));
274275
}
275276

276-
/** @dataProvider provideInvalidControllers */
277+
#[DataProvider('provideInvalidControllers')]
277278
public function testTheFollowingCodeShouldThrow(string $invalidControllerActionCode, string $expectedError): void
278279
{
279280
$codeWithDateTime = <<<'CODE'
@@ -325,7 +326,7 @@ class SomeController {
325326
$converter->convert([$codeWithDateTime]);
326327
}
327328

328-
public function provideInvalidControllers(): \Generator
329+
public static function provideInvalidControllers(): \Generator
329330
{
330331
yield [
331332
<<<'CODE'
File renamed without changes.

0 commit comments

Comments
 (0)