Skip to content

Commit 56af5fb

Browse files
⬆️ update PHPUnit to 9.6, DMA Extension 6.7 and upgrade tests (#3570)
* ⬆️ update PHPUnit to 9.6, DMA Extension 6.7 and upgrade tests * Set correct SYMFONY_PHPUNIT_VERSION, add failOnWarning config * Revert test changes * Use rector migration to resolve withConsecutive correctly * Resolve self::$container deprecation --------- Co-authored-by: Bob van de Vijver <bobvandevijver@hotmail.com>
1 parent 6ab6992 commit 56af5fb

12 files changed

Lines changed: 261 additions & 91 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ compose.override.yaml
8282
###> phpunit/phpunit ###
8383
/phpunit.xml
8484
/.phpunit.result.cache
85+
/.phpunit.cache
8586
###< phpunit/phpunit ###
8687

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"bobdenotter/configuration-notices": "^1.2",
9999
"bobdenotter/weatherwidget": "^1.1",
100100
"bolt/newswidget": "^1.3",
101-
"dama/doctrine-test-bundle": "^6.6.0",
101+
"dama/doctrine-test-bundle": "^6.0",
102102
"nyholm/psr7": "^1.4",
103103
"ondram/ci-detector": "^4.1",
104104
"php-http/curl-client": "^2.2",
@@ -108,7 +108,7 @@
108108
"phpstan/phpstan": "^1.2.0",
109109
"phpstan/phpstan-doctrine": "^1.0",
110110
"phpstan/phpstan-symfony": "^1.0.1",
111-
"phpunit/phpunit": "^8.5",
111+
"phpunit/phpunit": "^9.6",
112112
"se/selenium-server-standalone": "^3.141",
113113
"symfony/browser-kit": "^5.4",
114114
"symfony/css-selector": "^5.4",
@@ -123,7 +123,8 @@
123123
"composer/package-versions-deprecated": true,
124124
"drupol/composer-packages": true,
125125
"symfony/flex": true,
126-
"php-http/discovery": true
126+
"php-http/discovery": true,
127+
"dealerdirect/phpcodesniffer-composer-installer": false
127128
}
128129
},
129130
"extra": {

phpunit.xml.dist

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
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="http://schema.phpunit.de/6.1/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
65
backupGlobals="false"
76
colors="true"
8-
bootstrap="phpunit.bootstrap.php"
9-
>
7+
failOnWarning="true"
8+
bootstrap="phpunit.bootstrap.php">
109
<php>
1110
<ini name="error_reporting" value="-1" force="true"/>
1211
<env name="KERNEL_CLASS" value="Bolt\Kernel"/>
1312
<env name="APP_ENV" value="test" force="true"/>
1413
<env name="APP_DEBUG" value="1" force="true"/>
1514
<env name="APP_SECRET" value="5a79a1c866efef9ca1800f971d689f3e"/>
16-
<env name="SYMFONY_PHPUNIT_VERSION" value="7.2"/>
15+
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6"/>
1716
<!-- define your env variables for the test env here -->
18-
1917
<!-- ###+ doctrine/doctrine-bundle ### -->
2018
<env name="DATABASE_URL" value="sqlite::memory:" force="true"/>
2119
<!-- ###- doctrine/doctrine-bundle ### -->
@@ -26,15 +24,12 @@
2624
<!-- MAILER_DSN=smtp://localhost -->
2725
<!-- ###- symfony/mailer ### -->
2826
</php>
29-
3027
<testsuites>
3128
<testsuite name="Bolt Test Suite">
3229
<directory>tests/php/</directory>
3330
</testsuite>
3431
</testsuites>
35-
3632
<extensions>
37-
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
33+
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
3834
</extensions>
39-
4035
</phpunit>

symfony.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,6 @@
389389
"phpunit/php-timer": {
390390
"version": "2.1.2"
391391
},
392-
"phpunit/php-token-stream": {
393-
"version": "3.1.1"
394-
},
395392
"phpunit/phpunit": {
396393
"version": "4.7",
397394
"recipe": {
@@ -475,9 +472,6 @@
475472
"sebastian/recursion-context": {
476473
"version": "3.0.0"
477474
},
478-
"sebastian/resource-operations": {
479-
"version": "2.0.1"
480-
},
481475
"sebastian/type": {
482476
"version": "1.1.4"
483477
},

tests/php/Controller/Backend/ContentEditControllerTest.bak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ X-Robots-Tag: noindex
5151

5252
public function testCreateNewComplexNestedContent(): void
5353
{
54-
// (2) use self::$container to access the service container
55-
$container = self::$container;
54+
// (2) use self::getContainer() to access the service container
55+
$container = self::getContainer();
5656

5757
$admin = $this->getEm()->getRepository(User::class)->findOneByUsername('admin');
5858
$this->client->loginUser($admin);

tests/php/Menu/FrontendMenuBuilderTest.php

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

55
namespace Bolt\Tests\Menu;
66

7+
use RuntimeException;
78
use Bolt\Collection\DeepCollection;
89
use Bolt\Menu\FrontendMenuBuilder;
910
use Bolt\Tests\DbAwareTestCase;
@@ -31,7 +32,7 @@ protected function setUp(): void
3132
{
3233
parent::setUp();
3334

34-
$this->menuBuilder = self::$container->get(FrontendMenuBuilder::class);
35+
$this->menuBuilder = self::getContainer()->get(FrontendMenuBuilder::class);
3536

3637
// Setup mocks for testing the localized menu
3738
$this->twig = $this->createMock(Environment::class);
@@ -42,17 +43,29 @@ protected function setUp(): void
4243

4344
$this->request->attributes = $this->createMock(ParameterBag::class);
4445
$this->request->attributes
46+
->expects($matcher = $this->atMost(2))
4547
->method('get')
46-
->withConsecutive(['_route'], ['_route_params'])
47-
->willReturn('homepage_locale', []);
48+
->willReturnCallback(function (string $route) use ($matcher) {
49+
if ($matcher->getInvocationCount() === 1) {
50+
$this->assertSame('_route', $route);
51+
return 'homepage_locale';
52+
}
53+
54+
if ($matcher->getInvocationCount() === 2) {
55+
$this->assertSame('_route_params', $route);
56+
return [];
57+
}
58+
59+
throw new RuntimeException('Unexpected call');
60+
});
4861
$this->app = $this->createMock(AppVariable::class);
4962
$this->app->method('getRequest')->willReturn($this->request);
5063
$this->twig->method('getGlobals')->willReturn(['app' => $this->app]);
5164
}
5265

5366
public function testNonExistingMenu(): void
5467
{
55-
$this->expectException(\RuntimeException::class);
68+
$this->expectException(RuntimeException::class);
5669
$this->menuBuilder->buildMenu($this->twig, 'foo');
5770
}
5871

0 commit comments

Comments
 (0)