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 63a25e287..28e070199 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",
@@ -109,7 +109,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",
@@ -124,7 +124,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 853b21df5..82d97d1d1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,45 +1,37 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- tests/php/
-
-
-
-
-
-
-
+ bootstrap="phpunit.bootstrap.php">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tests/php/
+
+
+
+
+
diff --git a/symfony.lock b/symfony.lock
index bfc10e868..7e0f776d2 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -407,9 +407,6 @@
"phpunit/php-timer": {
"version": "2.1.2"
},
- "phpunit/php-token-stream": {
- "version": "3.1.1"
- },
"phpunit/phpunit": {
"version": "4.7",
"recipe": {
@@ -493,9 +490,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())))