Skip to content

Commit 3763f5c

Browse files
authored
Merge pull request #20 from Bee-Lab/upgrade-phpunit
⬆️ allow phpunit 10/11
2 parents 175d01e + b596502 commit 3763f5c

7 files changed

+61
-89
lines changed

.php-cs-fixer.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
'@Symfony' => true,
1313
'@Symfony:risky' => true,
1414
'@PHP80Migration:risky' => true,
15-
'@PHPUnit84Migration:risky' => true,
15+
'@PHP81Migration' => true,
16+
'@PHPUnit100Migration:risky' => true,
1617
'declare_strict_types' => false,
1718
'native_function_invocation' => ['include' => ['@all']],
1819
'php_unit_mock_short_will_return' => true,

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"doctrine/lexer": "^2.1",
2929
"doctrine/orm": "^2.16",
3030
"mikey179/vfsstream": "^1.6.7",
31-
"phpunit/phpunit": "^9.6",
31+
"phpunit/phpunit": "^10.5 || ^11.3",
3232
"symfony/doctrine-bridge": "^6.4 || ^7.0",
3333
"symfony/framework-bundle": "^6.4 || ^7.0",
3434
"symfony/mime": "^6.4 || ^7.0",

phpstan-baseline.neon

-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@ parameters:
44
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
55
count: 1
66
path: src/DependencyInjection/Configuration.php
7-
8-
-
9-
message: "#^PHPDoc tag @throws with type Doctrine\\\\DBAL\\\\DBALException\\|InvalidArgumentException is not subtype of Throwable$#"
10-
count: 1
11-
path: src/Test/WebTestCase.php
12-

phpunit.xml.dist

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- https://phpunit.readthedocs.io/en/9.5/configuration.html -->
2+
<!-- https://docs.phpunit.de/en/10.5/configuration.html -->
33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
backupGlobals="false"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
125
bootstrap="vendor/autoload.php"
6+
colors="true"
137
>
148
<testsuites>
159
<testsuite name="Project Test Suite">
1610
<directory>tests</directory>
1711
</testsuite>
1812
</testsuites>
19-
<coverage>
13+
<source>
2014
<include>
2115
<directory>src</directory>
2216
</include>
23-
</coverage>
17+
</source>
2418
</phpunit>

src/DependencyInjection/BeelabTestExtension.php

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
final class BeelabTestExtension extends Extension
99
{
10-
/**
11-
* @param array<int, mixed> $configs
12-
*/
1310
public function load(array $configs, ContainerBuilder $container): void
1411
{
1512
$configuration = new Configuration();

src/Test/WebTestCase.php

+9-17
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,11 @@
2626
abstract class WebTestCase extends SymfonyWebTestCase
2727
{
2828
protected static ?EntityManagerInterface $em = null;
29-
3029
protected static KernelBrowser $client;
31-
3230
private ?AbstractFixture $fixture = null;
33-
3431
protected static ?string $authUser = null;
35-
3632
protected static ?string $authPw = null;
37-
38-
/** @var ContainerInterface */
39-
protected static $container;
33+
protected static ?ContainerInterface $container = null;
4034

4135
protected function setUp(): void
4236
{
@@ -64,15 +58,13 @@ protected function setUp(): void
6458

6559
protected function tearDown(): void
6660
{
67-
if (null !== self::$em) {
68-
self::$em->getConnection()->close();
69-
}
61+
self::$em?->getConnection()->close();
7062
parent::tearDown();
7163
}
7264

7365
/**
7466
* Save request output and show it in the browser
75-
* See http://giorgiocefaro.com/blog/test-symfony-and-automatically-open-the-browser-with-the-response-content
67+
* See https://web.archive.org/web/20190205012632/https://giorgiocefaro.com/blog/test-symfony-and-automatically-open-the-browser-with-the-response-content
7668
* You can define a "domain" parameter with the current domain of your app.
7769
*/
7870
protected static function saveOutput(bool $delete = true): void
@@ -104,7 +96,7 @@ protected static function saveOutput(bool $delete = true): void
10496
*
10597
* @throws \InvalidArgumentException
10698
*/
107-
protected static function login(string $username = '[email protected]', string $firewall = null, string $service = null): void
99+
protected static function login(string $username = '[email protected]', ?string $firewall = null, ?string $service = null): void
108100
{
109101
$service ??= static::$container->getParameter('beelab_test.user_service');
110102
$object = static::$container->get($service);
@@ -180,13 +172,13 @@ protected static function getTxtFile(string $file = '0'): UploadedFile
180172
*
181173
* @param array<int, string> $fixtures e.g. ['UserData', 'OrderData']
182174
*
183-
* @throws \Doctrine\DBAL\DBALException
175+
* @throws \Doctrine\DBAL\Exception
184176
* @throws \InvalidArgumentException
185177
*/
186178
protected function loadFixtures(
187179
array $fixtures,
188180
string $namespace = 'App\\DataFixtures\\ORM\\',
189-
string $managerService = null,
181+
?string $managerService = null,
190182
bool $append = false,
191183
): void {
192184
if (null !== $managerService) {
@@ -238,7 +230,7 @@ protected static function commandTest(
238230
Command $command,
239231
array $arguments = [],
240232
array $otherCommands = [],
241-
array $inputs = null,
233+
?array $inputs = null,
242234
): string {
243235
$application = new Application(self::$client->getKernel());
244236
$application->add($command);
@@ -307,15 +299,15 @@ protected static function setSessionException(string $msg = 'error...'): void
307299
self::$client->getCookieJar()->set($cookie);
308300
}
309301

310-
protected static function clickLinkByData(string $dataName, string $parent = null): Crawler
302+
protected static function clickLinkByData(string $dataName, ?string $parent = null): Crawler
311303
{
312304
$selector = (null === $parent ? '' : $parent.' ').'a[data-'.$dataName.']';
313305
$linkNode = self::$client->getCrawler()->filter($selector);
314306

315307
return self::$client->click($linkNode->link());
316308
}
317309

318-
protected static function clickLinkBySelectorText(string $linkText, string $parent = null): Crawler
310+
protected static function clickLinkBySelectorText(string $linkText, ?string $parent = null): Crawler
319311
{
320312
$selector = (null === $parent ? '' : $parent.' ').'a:contains("'.$linkText.'")';
321313
$linkNode = self::$client->getCrawler()->filter($selector);

0 commit comments

Comments
 (0)