Skip to content

Commit 08f478a

Browse files
committed
update testing to PHPUnit 11 and PHP 8.2, 8.3
1 parent 5f8517c commit 08f478a

7 files changed

+68
-57
lines changed

Diff for: .github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
-
3131
name: Install composer dependencies
32-
run: composer install --prefer-dist --no-progress --no-suggest
32+
run: composer install --prefer-dist --no-progress
3333

3434
-
3535
name: PHP Linting
@@ -45,7 +45,7 @@ jobs:
4545
strategy:
4646
max-parallel: 2
4747
matrix:
48-
php-version: [8.0, 8.1, 8.2]
48+
php-version: [8.3, 8.2]
4949

5050
name: Unit (PHP ${{ matrix.php-version }})
5151
steps:
@@ -71,7 +71,7 @@ jobs:
7171

7272
-
7373
name: Install composer dependencies
74-
run: composer install --prefer-dist --no-progress --no-suggest
74+
run: composer install --prefer-dist --no-progress
7575

7676
-
7777
name: PHP Unit Testing

Diff for: composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"require-dev": {
2222
"editorconfig-checker/editorconfig-checker": "^10.0",
2323
"squizlabs/php_codesniffer": "^3.0",
24-
"phpunit/phpunit": "^9.2",
24+
"phpunit/phpunit": "^11.2",
2525
"symfony/var-dumper": "^5.1",
26-
"phpstan/phpstan": "^0.12.38"
26+
"phpstan/phpstan": "^1.11"
2727
},
2828
"autoload": {
2929
"psr-4": {

Diff for: tests/Unit/AbstractTest.php renamed to tests/Unit/AbstractTestClass.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Sitegeist\FluidComponentsLinter\Fluid\ViewHelper\ViewHelperResolver;
99
use TYPO3Fluid\Fluid\View\TemplateView;
1010

11-
abstract class AbstractTest extends TestCase
11+
abstract class AbstractTestClass extends TestCase
1212
{
1313
public function createComponent(string $componentSource, bool $strictSyntax = false): Component
1414
{

Diff for: tests/Unit/ComponentStructureTest.php

+23-15
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,67 @@
44

55
namespace Sitegeist\FluidComponentsLinter\Tests\Unit;
66

7-
final class ComponentStructureTest extends AbstractTest
7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
use PHPUnit\Framework\Attributes\Test;
9+
use Sitegeist\FluidComponentsLinter\Exception\ComponentStructureException;
10+
use Sitegeist\FluidComponentsLinter\Exception\StrictComponentStructureException;
11+
use TYPO3Fluid\Fluid\Core\Parser\Exception;
12+
13+
final class ComponentStructureTest extends AbstractTestClass
814
{
9-
public function dataProvider()
15+
public static function dataProvider()
1016
{
1117
return [
1218
'fluidSyntax' => [
1319
'<fc:component><fc:renderer></fc:component>',
1420
false,
15-
\TYPO3Fluid\Fluid\Core\Parser\Exception::class
21+
Exception::class
1622
],
1723
'missingComponent' => [
1824
'some content',
1925
false,
20-
\Sitegeist\FluidComponentsLinter\Exception\ComponentStructureException::class
26+
ComponentStructureException::class
2127
],
2228
'missingRenderer1' => [
2329
'<fc:component>some content</fc:component>',
2430
false,
25-
\Sitegeist\FluidComponentsLinter\Exception\ComponentStructureException::class
31+
ComponentStructureException::class
2632
],
2733
'missingRenderer2' => [
2834
'<fc:component><fc:param name="a" type="string" /></fc:component>',
2935
false,
30-
\Sitegeist\FluidComponentsLinter\Exception\ComponentStructureException::class
36+
ComponentStructureException::class
3137
],
3238
'strictComponentStructure1' => [
3339
'some content<fc:component><fc:renderer></fc:renderer></fc:component>',
3440
true,
35-
\Sitegeist\FluidComponentsLinter\Exception\StrictComponentStructureException::class
41+
StrictComponentStructureException::class
3642
],
3743
'strictComponentStructure2' => [
3844
'<fc:component>some content<fc:renderer></fc:renderer></fc:component>',
3945
true,
40-
\Sitegeist\FluidComponentsLinter\Exception\StrictComponentStructureException::class
46+
StrictComponentStructureException::class
4147
],
4248
'strictComponentStructure3' => [
4349
'<fc:component><fc:renderer></fc:renderer>some content</fc:component>',
4450
true,
45-
\Sitegeist\FluidComponentsLinter\Exception\StrictComponentStructureException::class
51+
StrictComponentStructureException::class
4652
],
4753
'strictComponentStructure4' => [
4854
'<fc:component><fc:renderer></fc:renderer></fc:component>some content',
4955
true,
50-
\Sitegeist\FluidComponentsLinter\Exception\StrictComponentStructureException::class
56+
StrictComponentStructureException::class
5157
]
5258
];
5359
}
5460

55-
/**
56-
* @dataProvider dataProvider
57-
*/
58-
public function testComponentStructure(string $componentSource, bool $strictSyntax, string $expectedException): void
59-
{
61+
#[Test]
62+
#[DataProvider('dataProvider')]
63+
public function testComponentStructure(
64+
string $componentSource,
65+
bool $strictSyntax,
66+
string $expectedException
67+
): void {
6068
$this->expectException($expectedException);
6169
$this->createComponent($componentSource, $strictSyntax);
6270
}

Diff for: tests/Unit/ComponentVariablesCheckTest.php

+15-14
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,71 @@
44

55
namespace Sitegeist\FluidComponentsLinter\Tests\Unit;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
use PHPUnit\Framework\Attributes\Test;
79
use Sitegeist\FluidComponentsLinter\CodeQuality\Check\ComponentVariablesCheck;
810
use Sitegeist\FluidComponentsLinter\CodeQuality\Issue\IssueInterface;
911

10-
final class ComponentVariablesCheckTest extends AbstractTest
12+
final class ComponentVariablesCheckTest extends AbstractTestClass
1113
{
12-
public function dataProvider()
14+
public static function dataProvider()
1315
{
1416
return [
1517
'requirePrefixerPrefixUsed' => [
16-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
18+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
1719
'<fc:component><fc:renderer>{component.prefix}</fc:renderer></fc:component>',
1820
0,
1921
IssueInterface::SEVERITY_MAJOR
2022
],
2123
'requirePrefixerClassUsed' => [
22-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
24+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
2325
'<fc:component><fc:renderer>{component.class}</fc:renderer></fc:component>',
2426
0,
2527
IssueInterface::SEVERITY_MAJOR
2628
],
2729
'requirePrefixerMinorSeverity' => [
28-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MINOR, false, IssueInterface::SEVERITY_MAJOR),
30+
static::generateConfiguration(true, IssueInterface::SEVERITY_MINOR, false, IssueInterface::SEVERITY_MAJOR),
2931
'<fc:component><fc:renderer></fc:renderer></fc:component>',
3032
1,
3133
IssueInterface::SEVERITY_MINOR
3234
],
3335
'requirePrefixerDisabled' => [
34-
$this->generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
36+
static::generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
3537
'<fc:component><fc:renderer></fc:renderer></fc:component>',
3638
0,
3739
IssueInterface::SEVERITY_MAJOR
3840
],
3941

4042
'requireClassClassUsed' => [
41-
$this->generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, true, IssueInterface::SEVERITY_MAJOR),
43+
static::generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, true, IssueInterface::SEVERITY_MAJOR),
4244
'<fc:component><fc:renderer>{class}</fc:renderer></fc:component>',
4345
0,
4446
IssueInterface::SEVERITY_MAJOR
4547
],
4648
'requireClassMinorSeverity' => [
47-
$this->generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, true, IssueInterface::SEVERITY_MINOR),
49+
static::generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, true, IssueInterface::SEVERITY_MINOR),
4850
'<fc:component><fc:renderer></fc:renderer></fc:component>',
4951
1,
5052
IssueInterface::SEVERITY_MINOR
5153
],
5254
'requireClassDisabled' => [
53-
$this->generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
55+
static::generateConfiguration(false, IssueInterface::SEVERITY_MAJOR, false, IssueInterface::SEVERITY_MAJOR),
5456
'<fc:component><fc:renderer></fc:renderer></fc:component>',
5557
0,
5658
IssueInterface::SEVERITY_MAJOR
5759
],
5860

5961
'combination' => [
60-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR, true, IssueInterface::SEVERITY_MAJOR),
62+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR, true, IssueInterface::SEVERITY_MAJOR),
6163
'<fc:component><fc:renderer></fc:renderer></fc:component>',
6264
2,
6365
IssueInterface::SEVERITY_MAJOR
6466
]
6567
];
6668
}
6769

68-
/**
69-
* @dataProvider dataProvider
70-
*/
70+
#[Test]
71+
#[DataProvider('dataProvider')]
7172
public function testChecksForMinimumMaximumParameterCount(
7273
array $configuration,
7374
string $componentSource,
@@ -83,7 +84,7 @@ public function testChecksForMinimumMaximumParameterCount(
8384
}
8485
}
8586

86-
public function generateConfiguration(
87+
public static function generateConfiguration(
8788
bool $requirePrefixer,
8889
string $requirePrefixerSeverity,
8990
bool $requireClass,

Diff for: tests/Unit/ContentVariableCheckTest.php

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,59 @@
33

44
namespace Sitegeist\FluidComponentsLinter\Tests\Unit;
55

6+
use PHPUnit\Framework\Attributes\DataProvider;
7+
use PHPUnit\Framework\Attributes\Test;
68
use Sitegeist\FluidComponentsLinter\CodeQuality\Check\ContentVariableCheck;
79
use Sitegeist\FluidComponentsLinter\CodeQuality\Issue\IssueInterface;
810

9-
final class ContentVariableCheckTest extends AbstractTest
11+
final class ContentVariableCheckTest extends AbstractTestClass
1012
{
11-
public function dataProvider()
13+
public static function dataProvider()
1214
{
1315
return [
1416
'rawViewHelper' => [
15-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
17+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
1618
'<fc:component><fc:renderer><f:format.raw>{content}</f:format.raw></fc:renderer></fc:component>',
1719
0,
1820
IssueInterface::SEVERITY_MAJOR
1921
],
2022
'rawInlineViewHelper' => [
21-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
23+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
2224
'<fc:component><fc:renderer>{content->f:format.raw()}</fc:renderer></fc:component>',
2325
0,
2426
IssueInterface::SEVERITY_MAJOR
2527
],
2628
'nestedRawViewHelper' => [
27-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
29+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
2830
'<fc:component><fc:renderer>
2931
<f:format.raw>content<my:viewhelper>content{content}content</my:viewhelper>content</f:format.raw>
3032
</fc:renderer></fc:component>',
3133
0,
3234
IssueInterface::SEVERITY_MAJOR
3335
],
3436
'missingViewHelper' => [
35-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
37+
static::generateConfiguration(true, IssueInterface::SEVERITY_MAJOR),
3638
'<fc:component><fc:renderer>{content}</fc:renderer></fc:component>',
3739
1,
3840
IssueInterface::SEVERITY_MAJOR
3941
],
4042
'minorSeverity' => [
41-
$this->generateConfiguration(true, IssueInterface::SEVERITY_MINOR),
43+
static::generateConfiguration(true, IssueInterface::SEVERITY_MINOR),
4244
'<fc:component><fc:renderer>{content}</fc:renderer></fc:component>',
4345
1,
4446
IssueInterface::SEVERITY_MINOR
4547
],
4648
'disabledCheck' => [
47-
$this->generateConfiguration(false, IssueInterface::SEVERITY_MAJOR),
49+
static::generateConfiguration(false, IssueInterface::SEVERITY_MAJOR),
4850
'<fc:component><fc:renderer>{content}</fc:renderer></fc:component>',
4951
0,
5052
IssueInterface::SEVERITY_MAJOR
5153
]
5254
];
5355
}
5456

55-
/**
56-
* @dataProvider dataProvider
57-
*/
57+
#[Test]
58+
#[DataProvider('dataProvider')]
5859
public function testChecksForMinimumMaximumParameterCount(
5960
array $configuration,
6061
string $componentSource,
@@ -70,7 +71,7 @@ public function testChecksForMinimumMaximumParameterCount(
7071
}
7172
}
7273

73-
public function generateConfiguration(bool $check, string $severity): array
74+
public static function generateConfiguration(bool $check, string $severity): array
7475
{
7576
return [
7677
'renderer' => [

Diff for: tests/Unit/ParamCountCheckTest.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33

44
namespace Sitegeist\FluidComponentsLinter\Tests\Unit;
55

6+
use PHPUnit\Framework\Attributes\DataProvider;
7+
use PHPUnit\Framework\Attributes\Test;
68
use Sitegeist\FluidComponentsLinter\CodeQuality\Check\ParamCountCheck;
79
use Sitegeist\FluidComponentsLinter\CodeQuality\Issue\IssueInterface;
810

9-
final class ParamCountCheckTest extends AbstractTest
11+
final class ParamCountCheckTest extends AbstractTestClass
1012
{
11-
public function dataProvider()
13+
public static function dataProvider()
1214
{
1315
return [
1416
'tooFewParameters' => [
15-
$this->generateConfiguration(3, 10, IssueInterface::SEVERITY_MAJOR),
17+
static::generateConfiguration(3, 10, IssueInterface::SEVERITY_MAJOR),
1618
'<fc:component><fc:renderer></fc:renderer></fc:component>',
1719
1,
1820
IssueInterface::SEVERITY_MAJOR
1921
],
2022
'parametersInAllowedRange' => [
21-
$this->generateConfiguration(3, 5, IssueInterface::SEVERITY_MAJOR),
23+
static::generateConfiguration(3, 5, IssueInterface::SEVERITY_MAJOR),
2224
'<fc:component>
2325
<fc:param name="a" type="string" />
2426
<fc:param name="b" type="string" />
@@ -29,7 +31,7 @@ public function dataProvider()
2931
IssueInterface::SEVERITY_MAJOR
3032
],
3133
'tooManyParameters' => [
32-
$this->generateConfiguration(1, 5, IssueInterface::SEVERITY_MAJOR),
34+
static::generateConfiguration(1, 5, IssueInterface::SEVERITY_MAJOR),
3335
'<fc:component>
3436
<fc:param name="a" type="string" />
3537
<fc:param name="b" type="string" />
@@ -43,17 +45,16 @@ public function dataProvider()
4345
IssueInterface::SEVERITY_MAJOR
4446
],
4547
'minorSeverity' => [
46-
$this->generateConfiguration(3, 10, IssueInterface::SEVERITY_MINOR),
48+
static::generateConfiguration(3, 10, IssueInterface::SEVERITY_MINOR),
4749
'<fc:component><fc:renderer></fc:renderer></fc:component>',
4850
1,
4951
IssueInterface::SEVERITY_MINOR
5052
],
5153
];
5254
}
5355

54-
/**
55-
* @dataProvider dataProvider
56-
*/
56+
#[Test]
57+
#[DataProvider('dataProvider')]
5758
public function testChecksForMinimumMaximumParameterCount(
5859
array $configuration,
5960
string $componentSource,
@@ -69,7 +70,7 @@ public function testChecksForMinimumMaximumParameterCount(
6970
}
7071
}
7172

72-
public function generateConfiguration(int $min, int $max, string $severity): array
73+
public static function generateConfiguration(int $min, int $max, string $severity): array
7374
{
7475
return [
7576
'params' => [

0 commit comments

Comments
 (0)