Skip to content

Commit 91b7157

Browse files
Upgrade PHPUnit and add PHP 8.4 to CI (#391)
1 parent f5db9a5 commit 91b7157

File tree

14 files changed

+101
-30
lines changed

14 files changed

+101
-30
lines changed

.github/workflows/test-application.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
database: postgres
2121
dependency-versions: 'lowest'
2222
tools: 'composer:v2'
23+
phpunit-config: 'phpunit-9.xml.dist'
2324
env:
2425
SYMFONY_DEPRECATIONS_HELPER: disabled
2526
DATABASE_URL: postgres://postgres:postgres@127.0.0.1/sulu_form_test?serverVersion=12.5
@@ -30,6 +31,7 @@ jobs:
3031
database: mysql
3132
dependency-versions: 'highest'
3233
tools: 'composer:v2'
34+
phpunit-config: 'phpunit-9.xml.dist'
3335
env:
3436
SYMFONY_DEPRECATIONS_HELPER: weak
3537
DATABASE_URL: mysql://root:root@127.0.0.1/sulu_form_test?serverVersion=5.7
@@ -57,6 +59,16 @@ jobs:
5759
DATABASE_COLLATE: utf8mb4_unicode_ci
5860

5961
- php-version: '8.2'
62+
database: postgres
63+
dependency-versions: 'highest'
64+
tools: 'composer:v2'
65+
env:
66+
SYMFONY_DEPRECATIONS_HELPER: weak
67+
DATABASE_URL: postgres://postgres:postgres@127.0.0.1/sulu_form_test?serverVersion=12.5
68+
DATABASE_CHARSET: UTF8
69+
DATABASE_COLLATE:
70+
71+
- php-version: '8.3'
6072
database: mysql
6173
dependency-versions: 'highest'
6274
tools: 'composer:v2'
@@ -66,10 +78,11 @@ jobs:
6678
DATABASE_CHARSET: utf8mb4
6779
DATABASE_COLLATE: utf8mb4_unicode_ci
6880

69-
- php-version: '8.3'
81+
- php-version: '8.4'
7082
database: mysql
7183
dependency-versions: 'highest'
7284
tools: 'composer:v2'
85+
composer-options: '--ignore-platform-reqs'
7386
env:
7487
SYMFONY_DEPRECATIONS_HELPER: weak
7588
DATABASE_URL: mysql://root:root@127.0.0.1/sulu_form_test?serverVersion=5.7
@@ -96,7 +109,7 @@ jobs:
96109

97110
steps:
98111
- name: Checkout project
99-
uses: actions/checkout@v2
112+
uses: actions/checkout@v4
100113

101114
- name: Install and configure PHP
102115
uses: shivammathur/setup-php@v2
@@ -106,11 +119,13 @@ jobs:
106119
tools: ${{ matrix.tools }}
107120
coverage: none
108121

109-
- name: Remove not required tooling for tests
110-
run: composer remove php-cs-fixer/shim "*phpstan*" --dev --no-update
122+
- name: Remove Lint Tools
123+
# These tools are not required to run tests, so we are removing them to improve dependency resolving and
124+
# testing lowest versions.
125+
run: composer remove "*php-cs-fixer*" "*phpstan*" "*rector*" --dev --no-update
111126

112127
- name: Install composer dependencies
113-
uses: ramsey/composer-install@v1
128+
uses: ramsey/composer-install@v2
114129
with:
115130
dependency-versions: ${{matrix.dependency-versions}}
116131
composer-options: ${{ matrix.composer-options }}
@@ -120,7 +135,7 @@ jobs:
120135
env: ${{ matrix.env }}
121136

122137
- name: Execute test cases
123-
run: time composer test
138+
run: time composer test -- --config ${{ matrix.phpunit-config || 'phpunit.xml.dist' }}
124139
env: ${{ matrix.env }}
125140

126141
lint:
@@ -131,18 +146,18 @@ jobs:
131146

132147
steps:
133148
- name: Checkout project
134-
uses: actions/checkout@v2
149+
uses: actions/checkout@v4
135150

136151
- name: Install and configure PHP
137152
uses: shivammathur/setup-php@v2
138153
with:
139-
php-version: 8.1
154+
php-version: 8.3
140155
extensions: 'imagick'
141156
tools: 'composer:v2'
142157
coverage: none
143158

144159
- name: Install composer dependencies
145-
uses: ramsey/composer-install@v1
160+
uses: ramsey/composer-install@v2
146161
with:
147162
dependency-versions: ${{matrix.dependency-versions}}
148163
composer-options: ${{ matrix.composer-options }}

Command/FormGeneratorCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
class FormGeneratorCommand extends Command
2424
{
25-
protected static $defaultName = 'sulu:form:generate-form';
26-
2725
/**
2826
* @var EntityManagerInterface
2927
*/
@@ -38,7 +36,7 @@ public function __construct(
3836
EntityManagerInterface $entityManager,
3937
WebspaceManagerInterface $webspaceManager
4038
) {
41-
parent::__construct(static::$defaultName);
39+
parent::__construct('sulu:form:generate-form');
4240
$this->entityManager = $entityManager;
4341
$this->webspaceManager = $webspaceManager;
4442
}

Tests/Application/config/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
require $file;
2323

24+
if (!\trait_exists(Prophecy\PhpUnit\ProphecyTrait::class)) { // backwards compatibility layer for < PHP 7.3
25+
require __DIR__ . '/../../prophecy-trait-bc-layer.php';
26+
}
27+
2428
// Load cached env vars if the .env.local.php file exists
2529
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
2630
if (\is_array($env = @include \dirname(__DIR__) . '/.env.local.php')) {

Tests/Functional/Mail/HelperTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class HelperTestCase extends SuluTestCase
3333

3434
protected function setUp(): void
3535
{
36-
static::$kernel = null; // requires as Symfony 4.4 does not unset on tearDown
37-
3836
$this->client = $this->createWebsiteClient();
3937
$this->purgeDatabase();
4038
$this->initPhpcr();

Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ public function testGetMetadataAttachmentEnglish(): void
238238
$this->assertEquals('number', $attachment->getItems()['options/max']->getType());
239239
$this->assertEquals(6, $attachment->getItems()['options/max']->getColspan());
240240

241-
$this->assertObjectHasAttribute('schema', $attachment);
242-
$this->assertObjectHasAttribute('key', $attachment);
241+
$this->assertTrue(\property_exists($attachment, 'schema'));
242+
$this->assertTrue(\property_exists($attachment, 'key'));
243243
}
244244

245245
public function testGetMetadataAttachmentGerman(): void

Tests/Unit/Configuration/FormConfigurationFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Sulu\Bundle\FormBundle\Tests\Unit\Configuration;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Prophecy\PhpUnit\ProphecyTrait;
1516
use Sulu\Bundle\FormBundle\Configuration\FormConfigurationFactory;
1617
use Sulu\Bundle\FormBundle\Configuration\MailConfigurationInterface;
1718
use Sulu\Bundle\FormBundle\Entity\Dynamic;
@@ -26,6 +27,8 @@
2627
*/
2728
class FormConfigurationFactoryTest extends TestCase
2829
{
30+
use ProphecyTrait;
31+
2932
public function testBuildByDynamic(): void
3033
{
3134
$dynamic = $this->createDynamic();

Tests/Unit/Event/ProtectedMediaSubscriberTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\ORM\QueryBuilder;
1616
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Prophecy\Prophecy\ObjectProphecy;
1920
use Sulu\Bundle\FormBundle\Event\ProtectedMediaSubscriber;
2021
use Sulu\Bundle\FormBundle\Tests\Application\Kernel;
@@ -29,6 +30,8 @@
2930

3031
class ProtectedMediaSubscriberTest extends TestCase
3132
{
33+
use ProphecyTrait;
34+
3235
/**
3336
* @var EntityManagerInterface|ObjectProphecy
3437
*/

Tests/Unit/Event/SendinblueListSubscriberTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use GuzzleHttp\Psr7\Response;
1616
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Prophecy\Prophecy\ObjectProphecy;
1920
use Psr\Http\Message\RequestInterface;
2021
use Sulu\Bundle\FormBundle\Configuration\FormConfiguration;
@@ -33,6 +34,8 @@
3334

3435
class SendinblueListSubscriberTest extends TestCase
3536
{
37+
use ProphecyTrait;
38+
3639
/**
3740
* @var RequestStack
3841
*/

Tests/Unit/Mail/MailerHelperTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Sulu\Bundle\FormBundle\Tests\Unit\Mail;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Prophecy\PhpUnit\ProphecyTrait;
1516
use Prophecy\Prophecy\ObjectProphecy;
1617
use Psr\Log\LoggerInterface;
1718
use Sulu\Bundle\FormBundle\Mail\MailerHelper;
@@ -27,6 +28,8 @@
2728
*/
2829
class MailerHelperTest extends TestCase
2930
{
31+
use ProphecyTrait;
32+
3033
/**
3134
* @var MailerHelper
3235
*/

Tests/prophecy-trait-bc-layer.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Sulu.
5+
*
6+
* (c) Sulu GmbH
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Prophecy\PhpUnit;
13+
14+
/**
15+
* @internal
16+
*/
17+
trait ProphecyTrait
18+
{
19+
}

0 commit comments

Comments
 (0)