Skip to content

Commit cb73a25

Browse files
authored
chore: use PHPUnit 11 (#20)
1 parent 11d0ef6 commit cb73a25

18 files changed

+94
-209
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
- name: "Install dependencies with composer"
100100
uses: "ramsey/composer-install@v3"
101101

102-
- name: "Run unit tests"
102+
- name: "Run tests"
103103
run: "vendor/bin/phpunit --configuration=phpunit.xml.dist --coverage-clover=.build/logs/clover.xml"
104104

105105
- name: 'Upload coverage reports to Codecov'

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cs:
1313

1414
.PHONY: tests
1515
tests:
16-
symfony php vendor/bin/phpunit -v
16+
symfony php vendor/bin/phpunit
1717

1818
.PHONY: refactoring
1919
refactoring:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=8.3",
14-
"oskarstark/enum-helper": "^1.5",
14+
"oskarstark/enum-helper": "^1.6",
1515
"psr/log": "^3.0",
1616
"storyblok/php-content-api-client": ">=1.0.0",
1717
"storyblok/php-tiptap-extension": "^1.0",
@@ -35,7 +35,7 @@
3535
"phpstan/extension-installer": "^1.0",
3636
"phpstan/phpstan": "^2.0",
3737
"phpstan/phpstan-webmozart-assert": "^2.0",
38-
"phpunit/phpunit": "^9.0",
38+
"phpunit/phpunit": "^11",
3939
"rector/rector": "^2.0",
4040
"symfony/event-dispatcher": "^6.0 || ^7.1",
4141
"thecodingmachine/phpstan-safe-rule": "^1.4"

phpunit.xml.dist

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
43
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
65
backupGlobals="false"
76
colors="true"
87
columns="max"
98
executionOrder="random"
10-
verbose="true"
9+
cacheDirectory=".phpunit.cache"
1110
>
1211
<php>
1312
<ini name="error_reporting" value="-1" />
@@ -20,17 +19,11 @@
2019
<testsuite name="all">
2120
<directory>tests</directory>
2221
</testsuite>
23-
<testsuite name="unit">
24-
<directory>tests/Unit</directory>
25-
</testsuite>
26-
<testsuite name="integration">
27-
<directory>tests/Unit</directory>
28-
</testsuite>
2922
</testsuites>
3023

31-
<filter>
32-
<whitelist>
24+
<source>
25+
<include>
3326
<directory>src</directory>
34-
</whitelist>
35-
</filter>
27+
</include>
28+
</source>
3629
</phpunit>

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$rectorConfig->sets([
4343
SetList::PHP_83,
4444
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
45-
PHPUnitSetList::PHPUNIT_90,
45+
PHPUnitSetList::PHPUNIT_110,
4646
SymfonySetList::SYMFONY_CODE_QUALITY,
4747
]);
4848

tests/Unit/Block/Attribute/AsBlockTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Storyblok\Bundle\Tests\Unit\Block\Attribute;
1515

16+
use PHPUnit\Framework\Attributes\Test;
1617
use PHPUnit\Framework\TestCase;
1718
use Storyblok\Bundle\Block\Attribute\AsBlock;
1819
use Storyblok\Bundle\Tests\Util\FakerTrait;
@@ -21,9 +22,7 @@ final class AsBlockTest extends TestCase
2122
{
2223
use FakerTrait;
2324

24-
/**
25-
* @test
26-
*/
25+
#[Test]
2726
public function defaults(): void
2827
{
2928
$block = new AsBlock();
@@ -32,10 +31,8 @@ public function defaults(): void
3231
self::assertNull($block->template);
3332
}
3433

35-
/**
36-
* @test
37-
*/
38-
public function name(): void
34+
#[Test]
35+
public function validName(): void
3936
{
4037
$block = new AsBlock(
4138
name: $expected = self::faker()->word(),
@@ -44,9 +41,7 @@ public function name(): void
4441
self::assertSame($expected, $block->name);
4542
}
4643

47-
/**
48-
* @test
49-
*/
44+
#[Test]
5045
public function template(): void
5146
{
5247
$block = new AsBlock(

tests/Unit/Block/BlockCollectionTest.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Storyblok\Bundle\Tests\Unit\Block;
1515

16+
use PHPUnit\Framework\Attributes\Test;
1617
use PHPUnit\Framework\TestCase;
1718
use Storyblok\Bundle\Block\BlockDefinition;
1819
use Storyblok\Bundle\Block\BlockRegistry;
@@ -24,9 +25,7 @@ final class BlockCollectionTest extends TestCase
2425
{
2526
use FakerTrait;
2627

27-
/**
28-
* @test
29-
*/
28+
#[Test]
3029
public function add(): void
3130
{
3231
$faker = self::faker();
@@ -37,9 +36,7 @@ public function add(): void
3736
self::assertCount(1, $collection);
3837
}
3938

40-
/**
41-
* @test
42-
*/
39+
#[Test]
4340
public function addWithArray(): void
4441
{
4542
$faker = self::faker();
@@ -52,9 +49,7 @@ public function addWithArray(): void
5249
self::assertCount(1, $collection);
5350
}
5451

55-
/**
56-
* @test
57-
*/
52+
#[Test]
5853
public function get(): void
5954
{
6055
$faker = self::faker();
@@ -65,9 +60,7 @@ public function get(): void
6560
self::assertSame($block, $collection::get($block->className));
6661
}
6762

68-
/**
69-
* @test
70-
*/
63+
#[Test]
7164
public function getThrowsExceptionWhenBlockDefinitionWasNotFound(): void
7265
{
7366
$faker = self::faker();
@@ -81,9 +74,7 @@ public function getThrowsExceptionWhenBlockDefinitionWasNotFound(): void
8174
$collection::get(\stdClass::class);
8275
}
8376

84-
/**
85-
* @test
86-
*/
77+
#[Test]
8778
public function byName(): void
8879
{
8980
$faker = self::faker();
@@ -94,9 +85,7 @@ public function byName(): void
9485
self::assertSame($block, $collection::byName($block->name));
9586
}
9687

97-
/**
98-
* @test
99-
*/
88+
#[Test]
10089
public function byNameThrowsExceptionWhenBlockDefinitionWasNotFound(): void
10190
{
10291
$faker = self::faker();

tests/Unit/Block/BlockDefinitionTest.php

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace Storyblok\Bundle\Tests\Unit\Block;
1515

16+
use Ergebnis\DataProvider\StringProvider;
17+
use PHPUnit\Framework\Attributes\DataProviderExternal;
18+
use PHPUnit\Framework\Attributes\Test;
1619
use PHPUnit\Framework\TestCase;
1720
use Storyblok\Bundle\Block\BlockDefinition;
1821
use Storyblok\Bundle\Tests\Double\Block\SampleBlock;
@@ -22,33 +25,26 @@ final class BlockDefinitionTest extends TestCase
2225
{
2326
use FakerTrait;
2427

25-
/**
26-
* @test
27-
*/
28-
public function name(): void
28+
#[Test]
29+
public function validName(): void
2930
{
3031
$faker = self::faker();
3132
$expected = $faker->word();
3233

3334
self::assertSame($expected, (new BlockDefinition($expected, SampleBlock::class, 'sample/block.html.twig'))->name);
3435
}
3536

36-
/**
37-
* @test
38-
*
39-
* @dataProvider \Ergebnis\DataProvider\StringProvider::blank()
40-
* @dataProvider \Ergebnis\DataProvider\StringProvider::empty()
41-
*/
37+
#[DataProviderExternal(StringProvider::class, 'blank')]
38+
#[DataProviderExternal(StringProvider::class, 'empty')]
39+
#[Test]
4240
public function nameInvalid(string $value): void
4341
{
4442
self::expectException(\InvalidArgumentException::class);
4543

4644
new BlockDefinition($value, SampleBlock::class, 'sample/block.html.twig');
4745
}
4846

49-
/**
50-
* @test
51-
*/
47+
#[Test]
5248
public function className(): void
5349
{
5450
$faker = self::faker();
@@ -57,22 +53,17 @@ public function className(): void
5753
self::assertSame($expected, (new BlockDefinition($faker->word(), $expected, 'sample/block.html.twig'))->className);
5854
}
5955

60-
/**
61-
* @test
62-
*
63-
* @dataProvider \Ergebnis\DataProvider\StringProvider::blank()
64-
* @dataProvider \Ergebnis\DataProvider\StringProvider::empty()
65-
*/
56+
#[DataProviderExternal(StringProvider::class, 'blank')]
57+
#[DataProviderExternal(StringProvider::class, 'empty')]
58+
#[Test]
6659
public function classNameInvalid(string $value): void
6760
{
6861
self::expectException(\InvalidArgumentException::class);
6962

7063
new BlockDefinition(self::faker()->word(), $value, 'sample/block.html.twig');
7164
}
7265

73-
/**
74-
* @test
75-
*/
66+
#[Test]
7667
public function classNameClassMustExist(): void
7768
{
7869
$faker = self::faker();
@@ -81,9 +72,7 @@ public function classNameClassMustExist(): void
8172
new BlockDefinition($faker->word(), $faker->word(), 'sample/block.html.twig');
8273
}
8374

84-
/**
85-
* @test
86-
*/
75+
#[Test]
8776
public function template(): void
8877
{
8978
$faker = self::faker();
@@ -92,22 +81,17 @@ public function template(): void
9281
self::assertSame($expected, (new BlockDefinition($faker->word(), SampleBlock::class, $expected))->template);
9382
}
9483

95-
/**
96-
* @test
97-
*
98-
* @dataProvider \Ergebnis\DataProvider\StringProvider::blank()
99-
* @dataProvider \Ergebnis\DataProvider\StringProvider::empty()
100-
*/
84+
#[DataProviderExternal(StringProvider::class, 'blank')]
85+
#[DataProviderExternal(StringProvider::class, 'empty')]
86+
#[Test]
10187
public function templateInvalid(string $value): void
10288
{
10389
self::expectException(\InvalidArgumentException::class);
10490

10591
new BlockDefinition(self::faker()->word(), SampleBlock::class, $value);
10692
}
10793

108-
/**
109-
* @test
110-
*/
94+
#[Test]
11195
public function fromArray(): void
11296
{
11397
$expected = new BlockDefinition(
@@ -123,9 +107,7 @@ public function fromArray(): void
123107
]));
124108
}
125109

126-
/**
127-
* @test
128-
*/
110+
#[Test]
129111
public function fromArraynameKeyMustExist(): void
130112
{
131113
self::expectException(\InvalidArgumentException::class);
@@ -136,9 +118,7 @@ public function fromArraynameKeyMustExist(): void
136118
]);
137119
}
138120

139-
/**
140-
* @test
141-
*/
121+
#[Test]
142122
public function fromArraynameInvalid(): void
143123
{
144124
self::expectException(\InvalidArgumentException::class);
@@ -150,9 +130,7 @@ public function fromArraynameInvalid(): void
150130
]);
151131
}
152132

153-
/**
154-
* @test
155-
*/
133+
#[Test]
156134
public function fromArrayClassNameKeyMustExist(): void
157135
{
158136
self::expectException(\InvalidArgumentException::class);
@@ -163,9 +141,7 @@ public function fromArrayClassNameKeyMustExist(): void
163141
]);
164142
}
165143

166-
/**
167-
* @test
168-
*/
144+
#[Test]
169145
public function fromArrayClassNameInvalid(): void
170146
{
171147
self::expectException(\InvalidArgumentException::class);
@@ -177,9 +153,7 @@ public function fromArrayClassNameInvalid(): void
177153
]);
178154
}
179155

180-
/**
181-
* @test
182-
*/
156+
#[Test]
183157
public function fromArrayTemplateKeyMustExist(): void
184158
{
185159
self::expectException(\InvalidArgumentException::class);
@@ -190,9 +164,7 @@ public function fromArrayTemplateKeyMustExist(): void
190164
]);
191165
}
192166

193-
/**
194-
* @test
195-
*/
167+
#[Test]
196168
public function fromArrayTemplateInvalid(): void
197169
{
198170
self::expectException(\InvalidArgumentException::class);

0 commit comments

Comments
 (0)