From d91183fc03ac9a5d55ef981108b4d679358f1e8a Mon Sep 17 00:00:00 2001
From: macintoshplus <814683+macintoshplus@users.noreply.github.com>
Date: Fri, 14 Mar 2025 11:09:09 +0100
Subject: [PATCH 1/5] :arrow_up: update PHPUnit to 9.6, DMA Extension 6.7 and
 upgrade tests
---
 .gitignore                                    |   1 +
 composer.json                                 |   7 +-
 phpunit.xml.dist                              |  14 +--
 symfony.lock                                  |   6 --
 tests/php/Menu/FrontendMenuBuilderTest.php    |  11 +-
 tests/php/Twig/ContentExtensionTestCase.php   | 100 +++++++++++-------
 tests/php/Twig/FieldExtensionTestCase.php     |   6 +-
 tests/php/Twig/SetcontentTokenParserTest.php  |   2 +-
 .../php/Widget/Injector/HtmlInjector2Test.php |  10 +-
 .../php/Widget/Injector/HtmlInjectorTest.php  |   4 +-
 tests/php/Widget/Injector/RequestZoneTest.php |   2 +-
 11 files changed, 92 insertions(+), 71 deletions(-)
diff --git a/.gitignore b/.gitignore
index cb7f3e4ba..c8aeadf8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -82,5 +82,6 @@ compose.override.yaml
 ###> phpunit/phpunit ###
 /phpunit.xml
 /.phpunit.result.cache
+/.phpunit.cache
 ###< phpunit/phpunit ###
 
diff --git a/composer.json b/composer.json
index 42aa83d4d..359d3efa1 100644
--- a/composer.json
+++ b/composer.json
@@ -98,7 +98,7 @@
         "bobdenotter/configuration-notices": "^1.2",
         "bobdenotter/weatherwidget": "^1.1",
         "bolt/newswidget": "^1.3",
-        "dama/doctrine-test-bundle": "^6.6.0",
+        "dama/doctrine-test-bundle": "^6.0",
         "nyholm/psr7": "^1.4",
         "ondram/ci-detector": "^4.1",
         "php-http/curl-client": "^2.2",
@@ -108,7 +108,7 @@
         "phpstan/phpstan": "^1.2.0",
         "phpstan/phpstan-doctrine": "^1.0",
         "phpstan/phpstan-symfony": "^1.0.1",
-        "phpunit/phpunit": "^8.5",
+        "phpunit/phpunit": "^9.6",
         "se/selenium-server-standalone": "^3.141",
         "symfony/browser-kit": "^5.4",
         "symfony/css-selector": "^5.4",
@@ -123,7 +123,8 @@
             "composer/package-versions-deprecated": true,
             "drupol/composer-packages": true,
             "symfony/flex": true,
-            "php-http/discovery": true
+            "php-http/discovery": true,
+            "dealerdirect/phpcodesniffer-composer-installer": false
         }
     },
     "extra": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 7f403a2c4..22aca538d 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,21 +1,18 @@
 
-
 
 
+         bootstrap="phpunit.bootstrap.php">
     
         
         
         
         
         
-        
+        
         
-
         
         
         
@@ -26,15 +23,12 @@
         
         
     
-
     
         
             tests/php/
         
     
-
     
-        
+        
     
-
 
diff --git a/symfony.lock b/symfony.lock
index fd3656993..0aca9af59 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -389,9 +389,6 @@
     "phpunit/php-timer": {
         "version": "2.1.2"
     },
-    "phpunit/php-token-stream": {
-        "version": "3.1.1"
-    },
     "phpunit/phpunit": {
         "version": "4.7",
         "recipe": {
@@ -475,9 +472,6 @@
     "sebastian/recursion-context": {
         "version": "3.0.0"
     },
-    "sebastian/resource-operations": {
-        "version": "2.0.1"
-    },
     "sebastian/type": {
         "version": "1.1.4"
     },
diff --git a/tests/php/Menu/FrontendMenuBuilderTest.php b/tests/php/Menu/FrontendMenuBuilderTest.php
index a612b79ae..5f742061a 100644
--- a/tests/php/Menu/FrontendMenuBuilderTest.php
+++ b/tests/php/Menu/FrontendMenuBuilderTest.php
@@ -43,8 +43,15 @@ protected function setUp(): void
         $this->request->attributes = $this->createMock(ParameterBag::class);
         $this->request->attributes
             ->method('get')
-            ->withConsecutive(['_route'], ['_route_params'])
-            ->willReturn('homepage_locale', []);
+            ->willReturnCallback(function ($param) {
+                if ($param === '_route') {
+                    return 'homepage';
+                }
+                if ($param === '_route_params') {
+                    return [];
+                }
+                return null;
+            });
         $this->app = $this->createMock(AppVariable::class);
         $this->app->method('getRequest')->willReturn($this->request);
         $this->twig->method('getGlobals')->willReturn(['app' => $this->app]);
diff --git a/tests/php/Twig/ContentExtensionTestCase.php b/tests/php/Twig/ContentExtensionTestCase.php
index f51081fc2..ead9667ff 100644
--- a/tests/php/Twig/ContentExtensionTestCase.php
+++ b/tests/php/Twig/ContentExtensionTestCase.php
@@ -46,19 +46,23 @@ protected function setUp(): void
     public function testTitle(): void
     {
         $this->definition->method('has')
-            ->withConsecutive(['title_format'])
-            ->willReturn(true);
+            ->willReturnCallback(fn($param) => $param === 'title_format');
         $this->definition->method('get')
-            ->withConsecutive(['title_format'])
-            ->willReturn('{number}: {title}');
+            ->willReturnCallback(fn($param) => $param === 'title_format' ? '{number}: {title}' : null);
         $this->content->method('getId')
             ->willReturn(1);
         $this->content->method('hasField')
-            ->withConsecutive(['number'], ['title'])
-            ->willReturnOnConsecutiveCalls(false, true);
+            ->willReturnCallback(function ($param) {
+                if ($param === 'number') {
+                    return false;
+                }
+                if ($param === 'title') {
+                    return true;
+                }
+                return false;
+            });
         $this->content->method('getField')
-            ->withConsecutive(['title'])
-            ->willReturn($this->field);
+            ->willReturnCallback(fn($param) => $param === 'title' ? $this->field : null);
         $this->field->method('isTranslatable')
             ->willReturn(false);
         $this->field->method('__toString')
@@ -70,17 +74,21 @@ public function testTitle(): void
     public function testTitleFields(): void
     {
         $this->definition->method('has')
-            ->withConsecutive(['title_format'])
-            ->willReturn(true);
+            ->willReturnCallback(fn($param) => $param === 'title_format');
         $this->definition->method('get')
-            ->withConsecutive(['title_format'])
-            ->willReturn('{number}: {title}');
+            ->willReturnCallback(fn($param) => $param === 'title_format' ? '{number}: {title}' : null);
         $this->content->method('getId')
             ->willReturn(1);
         $this->content->method('hasField')
-            ->withConsecutive(['number'], ['title'])
-            ->willReturnOnConsecutiveCalls(false, true);
-
+            ->willReturnCallback(function ($param) {
+                if ($param === 'number') {
+                    return false;
+                }
+                if ($param === 'title') {
+                    return true;
+                }
+                return false;
+            });
         $this->assertSame(['number', 'title'], $this->extension->getTitleFieldsNames($this->content));
     }
 
@@ -97,8 +105,7 @@ public function testContentImage(): void
         $this->assertNull($this->extension->getImage($this->content));
 
         $imagefield->method('get')
-            ->withConsecutive(['filename'])
-            ->willReturn('example.jpg');
+            ->willReturnCallback(fn($param) => $param === 'filename' ? 'example.jpg' : null);
         $this->assertSame($imagefield, $this->extension->getImage($this->content));
     }
 
@@ -108,8 +115,7 @@ public function testContentImageWithImagelist(): void
         $field2 = $this->createMock(Field::class);
         $image1 = $this->createMock(ImageField::class);
         $image1->method('get')
-            ->withConsecutive(['filename'])
-            ->willReturn('testimage.jpg');
+            ->willReturnCallback(fn($param) => $param === 'filename' ? 'testimage.jpg' : null);
         $image2 = $this->createMock(ImageField::class);
         $imagelist = $this->createMock(ImagelistField::class);
         $field3 = $this->createMock(Field::class);
@@ -129,23 +135,37 @@ public function testExcerptOnString(): void
     public function testExceptFromFormatShort(): void
     {
         $this->definition->method('get')
-            ->withConsecutive(['excerpt_format'])
-            ->willReturn('{subheading}: {body}');
+            ->willReturnCallback(fn($param) => $param === 'excerpt_format' ? '{subheading}: {body}' : null);
 
         $this->content->method('hasField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls(true, true);
+            ->willReturnCallback(function ($param) {
+                if ($param === 'subheading' || $param === 'body') {
+                    return true;
+                }
+                return false;
+            })
 
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $field1->method('__toString')->willReturn("In this week's news");
         $field2->method('__toString')->willReturn('Bolt 4 is pretty awesome.');
         $this->content->method('getField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls($field1, $field2);
+            ->willReturnCallback(function ($param) use($field1, $field2) {
+                if ($param === 'subheading') {
+                    return $field1;
+                }
+                if ($param === 'body') {
+                    return $field2;
+                }
+                return null;
+            });
         $this->definition->method('has')
-            ->withConsecutive(['excerpt_format'], ['subheading'], ['body'])
-            ->willReturn(true);
+            ->willReturnCallback(function ($param) {
+                if ($param === 'excerpt_format' || $param === 'subheading' || $param === 'body') {
+                    return true;
+                }
+                return false;
+            });
         $this->content->method('getId')
             ->willReturn(1);
 
@@ -155,27 +175,32 @@ public function testExceptFromFormatShort(): void
     public function testExceptFromFormatFull(): void
     {
         $this->definition->method('get')
-            ->withConsecutive(['excerpt_format'])
-            ->willReturn('{subheading}: {body}');
+            ->willReturnCallback(fn($param) => $param === 'excerpt_format' ? '{subheading}: {body}' : null);
 
         $this->content->method('hasField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls(true, true);
+            ->willReturnCallback(fn ($param) => $param === 'subheading' || $param === 'body');
 
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $field1->method('__toString')->willReturn("In this week's news");
         $field2->method('__toString')->willReturn('Bolt 4 is pretty awesome.');
         $this->content->method('getField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls($field1, $field2);
+            ->willReturnCallback(function ($param) use($field1, $field2) {
+                if ($param === 'subheading') {
+                    return $field1;
+                }
+                if ($param === 'body') {
+                    return $field2;
+                }
+                return null;
+            });
         $this->definition->method('has')
-            ->withConsecutive(['excerpt_format'], ['subheading'], ['body'])
-            ->willReturn(true);
+            ->willReturnCallback(fn ($param) => $param === 'excerpt_format' || $param === 'subheading' || $param === 'body');
         $this->content->method('getId')
             ->willReturn(1);
 
-        $this->assertSame("In this week's news: Bolt 4 is pretty awesome", $this->extension->getExcerpt($this->content));
+        $this->assertSame("In this week's news: Bolt 4 is pretty awesome",
+            $this->extension->getExcerpt($this->content));
     }
 
     public function testExcerptNoFormat(): void
@@ -198,7 +223,8 @@ public function testExcerptNoFormat(): void
         $this->content->method('getFields')
             ->willReturn(new ArrayCollection([$title, $subheading, $body]));
 
-        $this->assertSame('This subheading is OK. Here is the long body. It is OK too', $this->extension->getExcerpt($this->content));
+        $this->assertSame('This subheading is OK. Here is the long body. It is OK too',
+            $this->extension->getExcerpt($this->content));
         $this->assertSame('This subheading is OK. Here…', $this->extension->getExcerpt($this->content, 28));
     }
 
diff --git a/tests/php/Twig/FieldExtensionTestCase.php b/tests/php/Twig/FieldExtensionTestCase.php
index 7092bebcc..1c644622b 100644
--- a/tests/php/Twig/FieldExtensionTestCase.php
+++ b/tests/php/Twig/FieldExtensionTestCase.php
@@ -35,8 +35,7 @@ protected function setUp(): void
     public function testFieldLabel(): void
     {
         $this->fieldType->method('get')
-            ->withConsecutive(['label'])
-            ->wilLReturn('Test field');
+            ->willReturnCallback(fn ($param) => $param === 'label' ? 'Test field' : null);
 
         $this->assertSame('Test field', $this->extension->getLabel($this->field));
     }
@@ -44,8 +43,7 @@ public function testFieldLabel(): void
     public function testFieldType(): void
     {
         $this->fieldType->method('get')
-            ->withConsecutive(['type'])
-            ->willReturn('embed');
+            ->willReturnCallback(fn ($param) => $param === 'type' ? 'embed' : null);
 
         $this->assertSame('embed', $this->extension->getType($this->field));
     }
diff --git a/tests/php/Twig/SetcontentTokenParserTest.php b/tests/php/Twig/SetcontentTokenParserTest.php
index 302b0c641..b8a9da353 100644
--- a/tests/php/Twig/SetcontentTokenParserTest.php
+++ b/tests/php/Twig/SetcontentTokenParserTest.php
@@ -120,7 +120,7 @@ public function testParse(): void
         ]);
 
         $compiler = $this->getMockBuilder(Compiler::class)
-            ->setMethods(['raw', 'subcompile', 'write'])
+            ->onlyMethods(['raw', 'subcompile', 'write'])
             ->setConstructorArgs([$env])
             ->getMock();
 
diff --git a/tests/php/Widget/Injector/HtmlInjector2Test.php b/tests/php/Widget/Injector/HtmlInjector2Test.php
index c6ef0b85d..deec2dbdd 100644
--- a/tests/php/Widget/Injector/HtmlInjector2Test.php
+++ b/tests/php/Widget/Injector/HtmlInjector2Test.php
@@ -10,11 +10,11 @@
 class HtmlInjector2Test extends StringTestCase
 {
     public const HTML = '
foofoo
bar
';
 
-    public function providerInjectBeforeTagStart()
+    public static function providerInjectBeforeTagStart(): array
     {
         return [
             [
@@ -36,7 +36,7 @@ public function providerInjectBeforeTagStart()
         ];
     }
 
-    public function providerInjectBeforeTagEnd()
+    public static function providerInjectBeforeTagEnd(): array
     {
         return [
             [
@@ -58,7 +58,7 @@ public function providerInjectBeforeTagEnd()
         ];
     }
 
-    public function providerInjectAfterTagStart()
+    public static function providerInjectAfterTagStart():array
     {
         return [
             [
@@ -80,7 +80,7 @@ public function providerInjectAfterTagStart()
         ];
     }
 
-    public function providerInjectAfterTagEnd()
+    public static function providerInjectAfterTagEnd():array
     {
         return [
             [
diff --git a/tests/php/Widget/Injector/HtmlInjectorTest.php b/tests/php/Widget/Injector/HtmlInjectorTest.php
index 9076981d1..9ee992329 100644
--- a/tests/php/Widget/Injector/HtmlInjectorTest.php
+++ b/tests/php/Widget/Injector/HtmlInjectorTest.php
@@ -15,7 +15,7 @@ class HtmlInjectorTest extends StringTestCase
 {
     private const TEST_TEMPLATES_BASE_PATH = __DIR__ . '/../../../fixtures/HtmlInjector/';
 
-    public function providerTarget()
+    public static function providerTarget(): array
     {
         $list = (new Target())->listAll();
         $constants = (new Collection(array_keys($list)))
@@ -33,7 +33,7 @@ public function providerTarget()
         return $constants->toArray();
     }
 
-    public function providerAlwaysWorkingTarget()
+    public static function providerAlwaysWorkingTarget(): array
     {
         $list = (new Target())->listAll();
         $constants = (new Collection(array_keys($list)))
diff --git a/tests/php/Widget/Injector/RequestZoneTest.php b/tests/php/Widget/Injector/RequestZoneTest.php
index 4135a27b2..c8129d51f 100644
--- a/tests/php/Widget/Injector/RequestZoneTest.php
+++ b/tests/php/Widget/Injector/RequestZoneTest.php
@@ -11,7 +11,7 @@
 
 class RequestZoneTest extends TestCase
 {
-    public function providerZone()
+    public static function providerZone(): array
     {
         $o = new \ReflectionClass(RequestZone::class);
         $constants = (new Collection(array_keys($o->getConstants())))
From 3bf34d7eb269c334a63b5c39996b097a1d3a11bd Mon Sep 17 00:00:00 2001
From: Bob van de Vijver 
Date: Sun, 20 Jul 2025 15:47:10 +0200
Subject: [PATCH 2/5] Set correct SYMFONY_PHPUNIT_VERSION, add failOnWarning
 config
---
 phpunit.xml.dist | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 22aca538d..d83a45b17 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -4,6 +4,7 @@
          xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
          backupGlobals="false"
          colors="true"
+         failOnWarning="true"
          bootstrap="phpunit.bootstrap.php">
     
         
@@ -11,7 +12,7 @@
         
         
         
-        
+        
         
         
         
From db0ae82e1fab48f847b46d2742d3a6ca033e8576 Mon Sep 17 00:00:00 2001
From: Bob van de Vijver 
Date: Sun, 20 Jul 2025 15:53:17 +0200
Subject: [PATCH 3/5] Revert test changes
---
 tests/php/Menu/FrontendMenuBuilderTest.php    |  11 +-
 tests/php/Twig/ContentExtensionTestCase.php   | 100 +++++++-----------
 tests/php/Twig/FieldExtensionTestCase.php     |   6 +-
 tests/php/Twig/SetcontentTokenParserTest.php  |   2 +-
 .../php/Widget/Injector/HtmlInjector2Test.php |  10 +-
 .../php/Widget/Injector/HtmlInjectorTest.php  |   4 +-
 tests/php/Widget/Injector/RequestZoneTest.php |   2 +-
 7 files changed, 52 insertions(+), 83 deletions(-)
diff --git a/tests/php/Menu/FrontendMenuBuilderTest.php b/tests/php/Menu/FrontendMenuBuilderTest.php
index 5f742061a..a612b79ae 100644
--- a/tests/php/Menu/FrontendMenuBuilderTest.php
+++ b/tests/php/Menu/FrontendMenuBuilderTest.php
@@ -43,15 +43,8 @@ protected function setUp(): void
         $this->request->attributes = $this->createMock(ParameterBag::class);
         $this->request->attributes
             ->method('get')
-            ->willReturnCallback(function ($param) {
-                if ($param === '_route') {
-                    return 'homepage';
-                }
-                if ($param === '_route_params') {
-                    return [];
-                }
-                return null;
-            });
+            ->withConsecutive(['_route'], ['_route_params'])
+            ->willReturn('homepage_locale', []);
         $this->app = $this->createMock(AppVariable::class);
         $this->app->method('getRequest')->willReturn($this->request);
         $this->twig->method('getGlobals')->willReturn(['app' => $this->app]);
diff --git a/tests/php/Twig/ContentExtensionTestCase.php b/tests/php/Twig/ContentExtensionTestCase.php
index ead9667ff..f51081fc2 100644
--- a/tests/php/Twig/ContentExtensionTestCase.php
+++ b/tests/php/Twig/ContentExtensionTestCase.php
@@ -46,23 +46,19 @@ protected function setUp(): void
     public function testTitle(): void
     {
         $this->definition->method('has')
-            ->willReturnCallback(fn($param) => $param === 'title_format');
+            ->withConsecutive(['title_format'])
+            ->willReturn(true);
         $this->definition->method('get')
-            ->willReturnCallback(fn($param) => $param === 'title_format' ? '{number}: {title}' : null);
+            ->withConsecutive(['title_format'])
+            ->willReturn('{number}: {title}');
         $this->content->method('getId')
             ->willReturn(1);
         $this->content->method('hasField')
-            ->willReturnCallback(function ($param) {
-                if ($param === 'number') {
-                    return false;
-                }
-                if ($param === 'title') {
-                    return true;
-                }
-                return false;
-            });
+            ->withConsecutive(['number'], ['title'])
+            ->willReturnOnConsecutiveCalls(false, true);
         $this->content->method('getField')
-            ->willReturnCallback(fn($param) => $param === 'title' ? $this->field : null);
+            ->withConsecutive(['title'])
+            ->willReturn($this->field);
         $this->field->method('isTranslatable')
             ->willReturn(false);
         $this->field->method('__toString')
@@ -74,21 +70,17 @@ public function testTitle(): void
     public function testTitleFields(): void
     {
         $this->definition->method('has')
-            ->willReturnCallback(fn($param) => $param === 'title_format');
+            ->withConsecutive(['title_format'])
+            ->willReturn(true);
         $this->definition->method('get')
-            ->willReturnCallback(fn($param) => $param === 'title_format' ? '{number}: {title}' : null);
+            ->withConsecutive(['title_format'])
+            ->willReturn('{number}: {title}');
         $this->content->method('getId')
             ->willReturn(1);
         $this->content->method('hasField')
-            ->willReturnCallback(function ($param) {
-                if ($param === 'number') {
-                    return false;
-                }
-                if ($param === 'title') {
-                    return true;
-                }
-                return false;
-            });
+            ->withConsecutive(['number'], ['title'])
+            ->willReturnOnConsecutiveCalls(false, true);
+
         $this->assertSame(['number', 'title'], $this->extension->getTitleFieldsNames($this->content));
     }
 
@@ -105,7 +97,8 @@ public function testContentImage(): void
         $this->assertNull($this->extension->getImage($this->content));
 
         $imagefield->method('get')
-            ->willReturnCallback(fn($param) => $param === 'filename' ? 'example.jpg' : null);
+            ->withConsecutive(['filename'])
+            ->willReturn('example.jpg');
         $this->assertSame($imagefield, $this->extension->getImage($this->content));
     }
 
@@ -115,7 +108,8 @@ public function testContentImageWithImagelist(): void
         $field2 = $this->createMock(Field::class);
         $image1 = $this->createMock(ImageField::class);
         $image1->method('get')
-            ->willReturnCallback(fn($param) => $param === 'filename' ? 'testimage.jpg' : null);
+            ->withConsecutive(['filename'])
+            ->willReturn('testimage.jpg');
         $image2 = $this->createMock(ImageField::class);
         $imagelist = $this->createMock(ImagelistField::class);
         $field3 = $this->createMock(Field::class);
@@ -135,37 +129,23 @@ public function testExcerptOnString(): void
     public function testExceptFromFormatShort(): void
     {
         $this->definition->method('get')
-            ->willReturnCallback(fn($param) => $param === 'excerpt_format' ? '{subheading}: {body}' : null);
+            ->withConsecutive(['excerpt_format'])
+            ->willReturn('{subheading}: {body}');
 
         $this->content->method('hasField')
-            ->willReturnCallback(function ($param) {
-                if ($param === 'subheading' || $param === 'body') {
-                    return true;
-                }
-                return false;
-            })
+            ->withConsecutive(['subheading'], ['body'])
+            ->willReturnOnConsecutiveCalls(true, true);
 
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $field1->method('__toString')->willReturn("In this week's news");
         $field2->method('__toString')->willReturn('Bolt 4 is pretty awesome.');
         $this->content->method('getField')
-            ->willReturnCallback(function ($param) use($field1, $field2) {
-                if ($param === 'subheading') {
-                    return $field1;
-                }
-                if ($param === 'body') {
-                    return $field2;
-                }
-                return null;
-            });
+            ->withConsecutive(['subheading'], ['body'])
+            ->willReturnOnConsecutiveCalls($field1, $field2);
         $this->definition->method('has')
-            ->willReturnCallback(function ($param) {
-                if ($param === 'excerpt_format' || $param === 'subheading' || $param === 'body') {
-                    return true;
-                }
-                return false;
-            });
+            ->withConsecutive(['excerpt_format'], ['subheading'], ['body'])
+            ->willReturn(true);
         $this->content->method('getId')
             ->willReturn(1);
 
@@ -175,32 +155,27 @@ public function testExceptFromFormatShort(): void
     public function testExceptFromFormatFull(): void
     {
         $this->definition->method('get')
-            ->willReturnCallback(fn($param) => $param === 'excerpt_format' ? '{subheading}: {body}' : null);
+            ->withConsecutive(['excerpt_format'])
+            ->willReturn('{subheading}: {body}');
 
         $this->content->method('hasField')
-            ->willReturnCallback(fn ($param) => $param === 'subheading' || $param === 'body');
+            ->withConsecutive(['subheading'], ['body'])
+            ->willReturnOnConsecutiveCalls(true, true);
 
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $field1->method('__toString')->willReturn("In this week's news");
         $field2->method('__toString')->willReturn('Bolt 4 is pretty awesome.');
         $this->content->method('getField')
-            ->willReturnCallback(function ($param) use($field1, $field2) {
-                if ($param === 'subheading') {
-                    return $field1;
-                }
-                if ($param === 'body') {
-                    return $field2;
-                }
-                return null;
-            });
+            ->withConsecutive(['subheading'], ['body'])
+            ->willReturnOnConsecutiveCalls($field1, $field2);
         $this->definition->method('has')
-            ->willReturnCallback(fn ($param) => $param === 'excerpt_format' || $param === 'subheading' || $param === 'body');
+            ->withConsecutive(['excerpt_format'], ['subheading'], ['body'])
+            ->willReturn(true);
         $this->content->method('getId')
             ->willReturn(1);
 
-        $this->assertSame("In this week's news: Bolt 4 is pretty awesome",
-            $this->extension->getExcerpt($this->content));
+        $this->assertSame("In this week's news: Bolt 4 is pretty awesome", $this->extension->getExcerpt($this->content));
     }
 
     public function testExcerptNoFormat(): void
@@ -223,8 +198,7 @@ public function testExcerptNoFormat(): void
         $this->content->method('getFields')
             ->willReturn(new ArrayCollection([$title, $subheading, $body]));
 
-        $this->assertSame('This subheading is OK. Here is the long body. It is OK too',
-            $this->extension->getExcerpt($this->content));
+        $this->assertSame('This subheading is OK. Here is the long body. It is OK too', $this->extension->getExcerpt($this->content));
         $this->assertSame('This subheading is OK. Here…', $this->extension->getExcerpt($this->content, 28));
     }
 
diff --git a/tests/php/Twig/FieldExtensionTestCase.php b/tests/php/Twig/FieldExtensionTestCase.php
index 1c644622b..7092bebcc 100644
--- a/tests/php/Twig/FieldExtensionTestCase.php
+++ b/tests/php/Twig/FieldExtensionTestCase.php
@@ -35,7 +35,8 @@ protected function setUp(): void
     public function testFieldLabel(): void
     {
         $this->fieldType->method('get')
-            ->willReturnCallback(fn ($param) => $param === 'label' ? 'Test field' : null);
+            ->withConsecutive(['label'])
+            ->wilLReturn('Test field');
 
         $this->assertSame('Test field', $this->extension->getLabel($this->field));
     }
@@ -43,7 +44,8 @@ public function testFieldLabel(): void
     public function testFieldType(): void
     {
         $this->fieldType->method('get')
-            ->willReturnCallback(fn ($param) => $param === 'type' ? 'embed' : null);
+            ->withConsecutive(['type'])
+            ->willReturn('embed');
 
         $this->assertSame('embed', $this->extension->getType($this->field));
     }
diff --git a/tests/php/Twig/SetcontentTokenParserTest.php b/tests/php/Twig/SetcontentTokenParserTest.php
index b8a9da353..302b0c641 100644
--- a/tests/php/Twig/SetcontentTokenParserTest.php
+++ b/tests/php/Twig/SetcontentTokenParserTest.php
@@ -120,7 +120,7 @@ public function testParse(): void
         ]);
 
         $compiler = $this->getMockBuilder(Compiler::class)
-            ->onlyMethods(['raw', 'subcompile', 'write'])
+            ->setMethods(['raw', 'subcompile', 'write'])
             ->setConstructorArgs([$env])
             ->getMock();
 
diff --git a/tests/php/Widget/Injector/HtmlInjector2Test.php b/tests/php/Widget/Injector/HtmlInjector2Test.php
index deec2dbdd..c6ef0b85d 100644
--- a/tests/php/Widget/Injector/HtmlInjector2Test.php
+++ b/tests/php/Widget/Injector/HtmlInjector2Test.php
@@ -10,11 +10,11 @@
 class HtmlInjector2Test extends StringTestCase
 {
     public const HTML = 'foofoo
bar
';
 
-    public static function providerInjectBeforeTagStart(): array
+    public function providerInjectBeforeTagStart()
     {
         return [
             [
@@ -36,7 +36,7 @@ public static function providerInjectBeforeTagStart(): array
         ];
     }
 
-    public static function providerInjectBeforeTagEnd(): array
+    public function providerInjectBeforeTagEnd()
     {
         return [
             [
@@ -58,7 +58,7 @@ public static function providerInjectBeforeTagEnd(): array
         ];
     }
 
-    public static function providerInjectAfterTagStart():array
+    public function providerInjectAfterTagStart()
     {
         return [
             [
@@ -80,7 +80,7 @@ public static function providerInjectAfterTagStart():array
         ];
     }
 
-    public static function providerInjectAfterTagEnd():array
+    public function providerInjectAfterTagEnd()
     {
         return [
             [
diff --git a/tests/php/Widget/Injector/HtmlInjectorTest.php b/tests/php/Widget/Injector/HtmlInjectorTest.php
index 9ee992329..9076981d1 100644
--- a/tests/php/Widget/Injector/HtmlInjectorTest.php
+++ b/tests/php/Widget/Injector/HtmlInjectorTest.php
@@ -15,7 +15,7 @@ class HtmlInjectorTest extends StringTestCase
 {
     private const TEST_TEMPLATES_BASE_PATH = __DIR__ . '/../../../fixtures/HtmlInjector/';
 
-    public static function providerTarget(): array
+    public function providerTarget()
     {
         $list = (new Target())->listAll();
         $constants = (new Collection(array_keys($list)))
@@ -33,7 +33,7 @@ public static function providerTarget(): array
         return $constants->toArray();
     }
 
-    public static function providerAlwaysWorkingTarget(): array
+    public function providerAlwaysWorkingTarget()
     {
         $list = (new Target())->listAll();
         $constants = (new Collection(array_keys($list)))
diff --git a/tests/php/Widget/Injector/RequestZoneTest.php b/tests/php/Widget/Injector/RequestZoneTest.php
index c8129d51f..4135a27b2 100644
--- a/tests/php/Widget/Injector/RequestZoneTest.php
+++ b/tests/php/Widget/Injector/RequestZoneTest.php
@@ -11,7 +11,7 @@
 
 class RequestZoneTest extends TestCase
 {
-    public static function providerZone(): array
+    public function providerZone()
     {
         $o = new \ReflectionClass(RequestZone::class);
         $constants = (new Collection(array_keys($o->getConstants())))
From e84f53bfe1ddbdbb958efb275f87edc0adf2d58f Mon Sep 17 00:00:00 2001
From: Bob van de Vijver 
Date: Sun, 20 Jul 2025 16:11:30 +0200
Subject: [PATCH 4/5] Use rector migration to resolve withConsecutive correctly
---
 tests/php/Menu/FrontendMenuBuilderTest.php    |  19 +-
 tests/php/Twig/ContentExtensionTestCase.php   | 256 ++++++++++++++----
 tests/php/Twig/FieldExtensionTestCase.php     |  24 +-
 tests/php/Twig/TokenParserTestCase.php        |   6 +-
 tests/php/Utils/StrTest.php                   |   3 +-
 tests/php/Widget/Injector/RequestZoneTest.php |   3 +-
 6 files changed, 245 insertions(+), 66 deletions(-)
diff --git a/tests/php/Menu/FrontendMenuBuilderTest.php b/tests/php/Menu/FrontendMenuBuilderTest.php
index a612b79ae..ed5edf514 100644
--- a/tests/php/Menu/FrontendMenuBuilderTest.php
+++ b/tests/php/Menu/FrontendMenuBuilderTest.php
@@ -4,6 +4,7 @@
 
 namespace Bolt\Tests\Menu;
 
+use RuntimeException;
 use Bolt\Collection\DeepCollection;
 use Bolt\Menu\FrontendMenuBuilder;
 use Bolt\Tests\DbAwareTestCase;
@@ -42,9 +43,21 @@ protected function setUp(): void
 
         $this->request->attributes = $this->createMock(ParameterBag::class);
         $this->request->attributes
+            ->expects($matcher = $this->atMost(2))
             ->method('get')
-            ->withConsecutive(['_route'], ['_route_params'])
-            ->willReturn('homepage_locale', []);
+            ->willReturnCallback(function (string $route) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('_route', $route);
+                    return 'homepage_locale';
+                }
+
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('_route_params', $route);
+                    return [];
+                }
+
+                throw new RuntimeException('Unexpected call');
+            });
         $this->app = $this->createMock(AppVariable::class);
         $this->app->method('getRequest')->willReturn($this->request);
         $this->twig->method('getGlobals')->willReturn(['app' => $this->app]);
@@ -52,7 +65,7 @@ protected function setUp(): void
 
     public function testNonExistingMenu(): void
     {
-        $this->expectException(\RuntimeException::class);
+        $this->expectException(RuntimeException::class);
         $this->menuBuilder->buildMenu($this->twig, 'foo');
     }
 
diff --git a/tests/php/Twig/ContentExtensionTestCase.php b/tests/php/Twig/ContentExtensionTestCase.php
index f51081fc2..80167e079 100644
--- a/tests/php/Twig/ContentExtensionTestCase.php
+++ b/tests/php/Twig/ContentExtensionTestCase.php
@@ -16,6 +16,7 @@
 use Doctrine\Common\Collections\ArrayCollection;
 use PHPUnit\Framework\MockObject\MockObject;
 use Twig\Environment;
+use RuntimeException;
 
 class ContentExtensionTestCase extends DbAwareTestCase
 {
@@ -45,20 +46,50 @@ protected function setUp(): void
 
     public function testTitle(): void
     {
-        $this->definition->method('has')
-            ->withConsecutive(['title_format'])
-            ->willReturn(true);
-        $this->definition->method('get')
-            ->withConsecutive(['title_format'])
-            ->willReturn('{number}: {title}');
+        $this->definition
+            ->expects($matcher = $this->exactly(1))
+            ->method('has')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('title_format', $parameters[0]);
+                }
+                return true;
+            });
+        $this->definition
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('title_format', $parameters[0]);
+                }
+                return '{number}: {title}';
+            });
         $this->content->method('getId')
             ->willReturn(1);
-        $this->content->method('hasField')
-            ->withConsecutive(['number'], ['title'])
-            ->willReturnOnConsecutiveCalls(false, true);
-        $this->content->method('getField')
-            ->withConsecutive(['title'])
-            ->willReturn($this->field);
+        $this->content
+            ->expects($matcher = $this->exactly(2))
+            ->method('hasField')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('number', $parameters[0]);
+                    return false;
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('title', $parameters[0]);
+                    return true;
+                }
+
+                throw new RuntimeException('Unexpected call');
+            });
+        $this->content
+            ->expects($matcher = $this->exactly(1))
+            ->method('getField')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('title', $parameters[0]);
+                }
+                return $this->field;
+            });
         $this->field->method('isTranslatable')
             ->willReturn(false);
         $this->field->method('__toString')
@@ -69,17 +100,41 @@ public function testTitle(): void
 
     public function testTitleFields(): void
     {
-        $this->definition->method('has')
-            ->withConsecutive(['title_format'])
-            ->willReturn(true);
-        $this->definition->method('get')
-            ->withConsecutive(['title_format'])
-            ->willReturn('{number}: {title}');
+        $this->definition
+            ->expects($matcher = $this->exactly(1))
+            ->method('has')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('title_format', $parameters[0]);
+                }
+                return true;
+            });
+        $this->definition
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('title_format', $parameters[0]);
+                }
+                return '{number}: {title}';
+            });
         $this->content->method('getId')
             ->willReturn(1);
-        $this->content->method('hasField')
-            ->withConsecutive(['number'], ['title'])
-            ->willReturnOnConsecutiveCalls(false, true);
+        $this->content
+            ->expects($matcher = $this->exactly(2))
+            ->method('hasField')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('number', $parameters[0]);
+                    return false;
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('title', $parameters[0]);
+                    return true;
+                }
+
+                throw new RuntimeException('Unexpected call');
+        });
 
         $this->assertSame(['number', 'title'], $this->extension->getTitleFieldsNames($this->content));
     }
@@ -96,9 +151,15 @@ public function testContentImage(): void
 
         $this->assertNull($this->extension->getImage($this->content));
 
-        $imagefield->method('get')
-            ->withConsecutive(['filename'])
-            ->willReturn('example.jpg');
+        $imagefield
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('filename', $parameters[0]);
+                }
+                return 'example.jpg';
+            });
         $this->assertSame($imagefield, $this->extension->getImage($this->content));
     }
 
@@ -107,9 +168,14 @@ public function testContentImageWithImagelist(): void
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $image1 = $this->createMock(ImageField::class);
-        $image1->method('get')
-            ->withConsecutive(['filename'])
-            ->willReturn('testimage.jpg');
+        $image1->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('filename', $parameters[0]);
+                }
+                return 'testimage.jpg';
+            });
         $image2 = $this->createMock(ImageField::class);
         $imagelist = $this->createMock(ImagelistField::class);
         $field3 = $this->createMock(Field::class);
@@ -128,24 +194,66 @@ public function testExcerptOnString(): void
 
     public function testExceptFromFormatShort(): void
     {
-        $this->definition->method('get')
-            ->withConsecutive(['excerpt_format'])
-            ->willReturn('{subheading}: {body}');
-
-        $this->content->method('hasField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls(true, true);
+        $this->definition
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('excerpt_format', $parameters[0]);
+                }
+                return '{subheading}: {body}';
+            });
+
+        $this->content
+            ->expects($matcher = $this->exactly(2))
+            ->method('hasField')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('subheading', $parameters[0]);
+                    return true;
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('body', $parameters[0]);
+                    return true;
+                }
+
+                throw new RuntimeException('Unexpected call');
+            });
 
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $field1->method('__toString')->willReturn("In this week's news");
         $field2->method('__toString')->willReturn('Bolt 4 is pretty awesome.');
-        $this->content->method('getField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls($field1, $field2);
-        $this->definition->method('has')
-            ->withConsecutive(['excerpt_format'], ['subheading'], ['body'])
-            ->willReturn(true);
+        $this->content
+            ->expects($matcher = $this->exactly(2))
+            ->method('getField')
+            ->willReturnCallback(function (...$parameters) use ($matcher, $field1, $field2) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('subheading', $parameters[0]);
+                    return $field1;
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('body', $parameters[0]);
+                    return $field2;
+                }
+
+                throw new RuntimeException('Unexpected call');
+            });
+        $this->definition
+            ->expects($matcher = $this->exactly(3))
+            ->method('has')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('excerpt_format', $parameters[0]);
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('subheading', $parameters[0]);
+                }
+                if ($matcher->getInvocationCount() === 3) {
+                    $this->assertSame('body', $parameters[0]);
+                }
+                return true;
+            });
         $this->content->method('getId')
             ->willReturn(1);
 
@@ -154,24 +262,66 @@ public function testExceptFromFormatShort(): void
 
     public function testExceptFromFormatFull(): void
     {
-        $this->definition->method('get')
-            ->withConsecutive(['excerpt_format'])
-            ->willReturn('{subheading}: {body}');
-
-        $this->content->method('hasField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls(true, true);
+        $this->definition
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('excerpt_format', $parameters[0]);
+                }
+                return '{subheading}: {body}';
+            });
+
+        $this->content
+            ->expects($matcher = $this->exactly(2))
+            ->method('hasField')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('subheading', $parameters[0]);
+                    return true;
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('body', $parameters[0]);
+                    return true;
+                }
+
+                throw new RuntimeException('Unexpected call');
+            });
 
         $field1 = $this->createMock(Field::class);
         $field2 = $this->createMock(Field::class);
         $field1->method('__toString')->willReturn("In this week's news");
         $field2->method('__toString')->willReturn('Bolt 4 is pretty awesome.');
-        $this->content->method('getField')
-            ->withConsecutive(['subheading'], ['body'])
-            ->willReturnOnConsecutiveCalls($field1, $field2);
-        $this->definition->method('has')
-            ->withConsecutive(['excerpt_format'], ['subheading'], ['body'])
-            ->willReturn(true);
+        $this->content
+            ->expects($matcher = $this->exactly(2))
+            ->method('getField')
+            ->willReturnCallback(function (...$parameters) use ($matcher, $field1, $field2) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('subheading', $parameters[0]);
+                    return $field1;
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('body', $parameters[0]);
+                    return $field2;
+                }
+
+                throw new RuntimeException('Unexpected call');
+            });
+        $this->definition
+            ->expects($matcher = $this->exactly(3))
+            ->method('has')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('excerpt_format', $parameters[0]);
+                }
+                if ($matcher->getInvocationCount() === 2) {
+                    $this->assertSame('subheading', $parameters[0]);
+                }
+                if ($matcher->getInvocationCount() === 3) {
+                    $this->assertSame('body', $parameters[0]);
+                }
+                return true;
+            });
         $this->content->method('getId')
             ->willReturn(1);
 
diff --git a/tests/php/Twig/FieldExtensionTestCase.php b/tests/php/Twig/FieldExtensionTestCase.php
index 7092bebcc..10523ebbd 100644
--- a/tests/php/Twig/FieldExtensionTestCase.php
+++ b/tests/php/Twig/FieldExtensionTestCase.php
@@ -34,18 +34,30 @@ protected function setUp(): void
 
     public function testFieldLabel(): void
     {
-        $this->fieldType->method('get')
-            ->withConsecutive(['label'])
-            ->wilLReturn('Test field');
+        $this->fieldType
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('label', $parameters[0]);
+                }
+                return 'Test field';
+            });
 
         $this->assertSame('Test field', $this->extension->getLabel($this->field));
     }
 
     public function testFieldType(): void
     {
-        $this->fieldType->method('get')
-            ->withConsecutive(['type'])
-            ->willReturn('embed');
+        $this->fieldType
+            ->expects($matcher = $this->exactly(1))
+            ->method('get')
+            ->willReturnCallback(function (...$parameters) use ($matcher) {
+                if ($matcher->getInvocationCount() === 1) {
+                    $this->assertSame('type', $parameters[0]);
+                }
+                return 'embed';
+            });
 
         $this->assertSame('embed', $this->extension->getType($this->field));
     }
diff --git a/tests/php/Twig/TokenParserTestCase.php b/tests/php/Twig/TokenParserTestCase.php
index 58b848ace..f84a8d61d 100644
--- a/tests/php/Twig/TokenParserTestCase.php
+++ b/tests/php/Twig/TokenParserTestCase.php
@@ -4,6 +4,8 @@
 
 namespace Bolt\Tests\Twig;
 
+use PHPUnit\Framework\TestCase;
+use ReflectionProperty;
 use Twig\Environment;
 use Twig\Loader\LoaderInterface;
 use Twig\Node\Node;
@@ -17,7 +19,7 @@
  * @author Gawain Lynch 
  * @author Bob den Otter 
  */
-abstract class TokenParserTestCase extends \PHPUnit\Framework\TestCase
+abstract class TokenParserTestCase extends TestCase
 {
     protected function getParser(TokenStream $tokenStream, AbstractTokenParser $testParser): Parser
     {
@@ -26,7 +28,7 @@ protected function getParser(TokenStream $tokenStream, AbstractTokenParser $test
         $parser = new Parser($env);
         $parser->setParent(new Node());
 
-        $p = new \ReflectionProperty($parser, 'stream');
+        $p = new ReflectionProperty($parser, 'stream');
         $p->setAccessible(true);
         $p->setValue($parser, $tokenStream);
 
diff --git a/tests/php/Utils/StrTest.php b/tests/php/Utils/StrTest.php
index 2c2de5bd2..8118ecd38 100644
--- a/tests/php/Utils/StrTest.php
+++ b/tests/php/Utils/StrTest.php
@@ -4,9 +4,10 @@
 
 namespace Bolt\Tests\Utils;
 
+use PHPUnit\Framework\TestCase;
 use Bolt\Common\Str;
 
-class StrTest extends \PHPUnit\Framework\TestCase
+class StrTest extends TestCase
 {
     public function testSlug(): void
     {
diff --git a/tests/php/Widget/Injector/RequestZoneTest.php b/tests/php/Widget/Injector/RequestZoneTest.php
index 4135a27b2..3b3635b57 100644
--- a/tests/php/Widget/Injector/RequestZoneTest.php
+++ b/tests/php/Widget/Injector/RequestZoneTest.php
@@ -4,6 +4,7 @@
 
 namespace Bolt\Tests\Widget\Injector;
 
+use ReflectionClass;
 use Bolt\Widget\Injector\RequestZone;
 use PHPUnit\Framework\TestCase;
 use Symfony\Component\HttpFoundation\Request;
@@ -13,7 +14,7 @@ class RequestZoneTest extends TestCase
 {
     public function providerZone()
     {
-        $o = new \ReflectionClass(RequestZone::class);
+        $o = new ReflectionClass(RequestZone::class);
         $constants = (new Collection(array_keys($o->getConstants())))
             ->filter(function ($v) {
                 return mb_strpos($v, 'NOWHERE') === false;
From a94be52404cd9437da506656218a8f66267b0d99 Mon Sep 17 00:00:00 2001
From: Bob van de Vijver 
Date: Sun, 20 Jul 2025 16:12:32 +0200
Subject: [PATCH 5/5] Resolve self::$container deprecation
---
 tests/php/Controller/Backend/ContentEditControllerTest.bak | 4 ++--
 tests/php/Menu/FrontendMenuBuilderTest.php                 | 2 +-
 tests/php/Twig/ContentExtensionTestCase.php                | 2 +-
 tests/php/Twig/FieldExtensionTestCase.php                  | 2 +-
 tests/php/Twig/TextExtensionTestCase.php                   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/php/Controller/Backend/ContentEditControllerTest.bak b/tests/php/Controller/Backend/ContentEditControllerTest.bak
index b7f0d64b8..ecbd10af3 100644
--- a/tests/php/Controller/Backend/ContentEditControllerTest.bak
+++ b/tests/php/Controller/Backend/ContentEditControllerTest.bak
@@ -51,8 +51,8 @@ X-Robots-Tag:           noindex
 
     public function testCreateNewComplexNestedContent(): void
     {
-        // (2) use self::$container to access the service container
-        $container = self::$container;
+        // (2) use self::getContainer() to access the service container
+        $container = self::getContainer();
 
         $admin = $this->getEm()->getRepository(User::class)->findOneByUsername('admin');
         $this->client->loginUser($admin);
diff --git a/tests/php/Menu/FrontendMenuBuilderTest.php b/tests/php/Menu/FrontendMenuBuilderTest.php
index ed5edf514..0a2033894 100644
--- a/tests/php/Menu/FrontendMenuBuilderTest.php
+++ b/tests/php/Menu/FrontendMenuBuilderTest.php
@@ -32,7 +32,7 @@ protected function setUp(): void
     {
         parent::setUp();
 
-        $this->menuBuilder = self::$container->get(FrontendMenuBuilder::class);
+        $this->menuBuilder = self::getContainer()->get(FrontendMenuBuilder::class);
 
         // Setup mocks for testing the localized menu
         $this->twig = $this->createMock(Environment::class);
diff --git a/tests/php/Twig/ContentExtensionTestCase.php b/tests/php/Twig/ContentExtensionTestCase.php
index 80167e079..3c7fe5550 100644
--- a/tests/php/Twig/ContentExtensionTestCase.php
+++ b/tests/php/Twig/ContentExtensionTestCase.php
@@ -36,7 +36,7 @@ protected function setUp(): void
     {
         parent::setUp();
 
-        $this->extension = self::$container->get(ContentExtension::class);
+        $this->extension = self::getContainer()->get(ContentExtension::class);
         $this->content = $this->createMock(Content::class);
         $this->definition = $this->createMock(ContentType::class);
         $this->content->method('getDefinition')
diff --git a/tests/php/Twig/FieldExtensionTestCase.php b/tests/php/Twig/FieldExtensionTestCase.php
index 10523ebbd..fbe751634 100644
--- a/tests/php/Twig/FieldExtensionTestCase.php
+++ b/tests/php/Twig/FieldExtensionTestCase.php
@@ -24,7 +24,7 @@ protected function setUp(): void
     {
         parent::setUp();
 
-        $this->extension = self::$container->get(FieldExtension::class);
+        $this->extension = self::getContainer()->get(FieldExtension::class);
 
         $this->field = $this->createMock(Field::class);
         $this->fieldType = $this->createMock(FieldType::class);
diff --git a/tests/php/Twig/TextExtensionTestCase.php b/tests/php/Twig/TextExtensionTestCase.php
index 486ade7cf..738bbd0ab 100644
--- a/tests/php/Twig/TextExtensionTestCase.php
+++ b/tests/php/Twig/TextExtensionTestCase.php
@@ -16,7 +16,7 @@ protected function setUp(): void
     {
         parent::setUp();
 
-        $this->extension = self::$container->get(TextExtension::class);
+        $this->extension = self::getContainer()->get(TextExtension::class);
     }
 
     public function testPlainText(): void