Skip to content

Commit fbd753e

Browse files
Upgrade PHPUnit and add PHP 8.4 to CI (#134)
* Upgrade PHPUnit and add PHP 8.4 to CI * Remove unnecessary conflicts * Use prophecy trait * Add PHPUnit bridge * Use prophecy-phpunit 2 * Update phpunit file * Update PHPUnit * Move lint to own CI task * Add CI for lowest version * Move phpstan config from composer.json to phpstan.neon file * Update lowest task * Fix lowest CI * Remove not longer required gedmo hack
1 parent ca49c52 commit fbd753e

18 files changed

+151
-57
lines changed

.env.dist

-24
This file was deleted.

.github/workflows/test-application.yaml

+57-8
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
env:
16-
DATABASE_URL: mysql://root:[email protected]:3306/sulu_test?serverVersion=5.7
16+
DATABASE_URL: mysql://root:[email protected]:3306/sulu_test?serverVersion=8.0
1717

1818
strategy:
1919
fail-fast: false
2020
matrix:
2121
include:
22+
- php-version: '7.4'
23+
dependency-versions: 'lowest'
24+
php-extensions: 'ctype, iconv, mysql, imagick'
25+
tools: 'composer:v2'
26+
lint: false
27+
phpunit-config: 'phpunit-9.xml.dist'
28+
env:
29+
SYMFONY_DEPRECATIONS_HELPER: weak
30+
2231
- php-version: '7.4'
2332
dependency-versions: 'highest'
2433
php-extensions: 'ctype, iconv, mysql, imagick'
2534
tools: 'composer:v2'
2635
lint: false
36+
phpunit-config: 'phpunit-9.xml.dist'
2737
env:
2838
SYMFONY_DEPRECATIONS_HELPER: weak
2939

@@ -55,6 +65,14 @@ jobs:
5565
lint: true
5666
env:
5767
SYMFONY_DEPRECATIONS_HELPER: weak
68+
- php-version: '8.4'
69+
dependency-versions: 'highest'
70+
composer-options: '--ignore-platform-reqs'
71+
php-extensions: 'ctype, iconv, mysql, imagick'
72+
tools: 'composer:v2'
73+
lint: true
74+
env:
75+
SYMFONY_DEPRECATIONS_HELPER: weak
5876

5977
services:
6078
mysql:
@@ -67,7 +85,7 @@ jobs:
6785

6886
steps:
6987
- name: Checkout project
70-
uses: actions/checkout@v2
88+
uses: actions/checkout@v4
7189

7290
- name: Install and configure PHP
7391
uses: shivammathur/setup-php@v2
@@ -77,20 +95,51 @@ jobs:
7795
tools: ${{ matrix.tools }}
7896
coverage: none
7997

98+
- name: Allow old composer plugin
99+
run: composer config --no-plugins allow-plugins.ocramius/package-versions true # todo remove when not longer required for lowest task
100+
101+
- name: Remove Lint Tools
102+
# These tools are not required to run tests, so we are removing them to improve dependency resolving and
103+
# testing lowest versions.
104+
run: composer remove "*php-cs-fixer*" "*phpstan*" "*rector*" --dev --no-update
105+
80106
- name: Install composer dependencies
81107
uses: ramsey/composer-install@v2
82108
with:
83109
dependency-versions: ${{matrix.dependency-versions}}
110+
composer-options: ${{matrix.composer-options}}
84111

85112
- name: Bootstrap test environment
86113
run: composer initialize
87114
env: ${{ matrix.env }}
88115

89-
- name: Lint code
90-
if: ${{ matrix.lint }}
91-
run: composer lint
92-
env: ${{ matrix.env }}
93-
94116
- name: Execute test cases
95-
run: time composer test
117+
run: time composer test -- --config ${{ matrix.phpunit-config || 'phpunit.xml.dist' }}
96118
env: ${{ matrix.env }}
119+
120+
lint:
121+
name: "PHP Lint"
122+
runs-on: ubuntu-latest
123+
124+
env:
125+
DATABASE_URL: mysql://root:[email protected]:3306/sulu_test?serverVersion=8.0
126+
127+
steps:
128+
- name: Checkout project
129+
uses: actions/checkout@v4
130+
131+
- name: Install and configure PHP
132+
uses: shivammathur/setup-php@v2
133+
with:
134+
php-version: 8.3
135+
extensions: 'ctype, iconv, mysql, imagick'
136+
tools: 'composer:v2'
137+
coverage: none
138+
139+
- name: Install composer dependencies
140+
uses: ramsey/composer-install@v2
141+
with:
142+
dependency-versions: highest
143+
144+
- name: Lint code
145+
run: composer lint

Tests/Application/Kernel.php

+8
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,12 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
3737

3838
$loader->load(__DIR__ . '/config/config_' . $this->getContext() . '.yml');
3939
}
40+
41+
protected function getKernelParameters(): array
42+
{
43+
$parameters = parent::getKernelParameters();
44+
$parameters['kernel.root_dir'] = __DIR__; // TODO remove when lowest version increased
45+
46+
return $parameters;
47+
}
4048
}

Tests/Application/config/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ services:
3131

3232
sulu_media.storage:
3333
class: Sulu\Bundle\SyliusConsumerBundle\Tests\Functional\Mocks\Storage
34-
public: true
34+
public: true

Tests/Functional/Adapter/ImageMediaAdapterTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Doctrine\ORM\Id\AssignedGenerator;
1717
use Doctrine\ORM\Mapping\ClassMetadata;
1818
use Prophecy\Argument;
19+
use Prophecy\PhpUnit\ProphecyTrait;
1920
use Prophecy\Prophecy\ObjectProphecy;
2021
use Sulu\Bundle\MediaBundle\Entity\CollectionType;
2122
use Sulu\Bundle\MediaBundle\Entity\MediaType;
@@ -33,6 +34,7 @@
3334

3435
class ImageMediaAdapterTest extends KernelTestCase
3536
{
37+
use ProphecyTrait;
3638
use PurgeDatabaseTrait;
3739

3840
/**

Tests/Unit/Entity/ImageMediaBridgeTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
namespace Sulu\Bundle\SyliusConsumerBundle\Tests\Unit\Entity;
1515

1616
use PHPUnit\Framework\TestCase;
17+
use Prophecy\PhpUnit\ProphecyTrait;
1718
use Sulu\Bundle\MediaBundle\Entity\MediaInterface;
1819
use Sulu\Bundle\SyliusConsumerBundle\Entity\ImageMediaBridge;
1920

2021
class ImageMediaBridgeTest extends TestCase
2122
{
23+
use ProphecyTrait;
24+
2225
public function testGetId(): void
2326
{
2427
$media = $this->prophesize(MediaInterface::class);

Tests/Unit/Entity/TaxonCategoryBridgeTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
namespace Sulu\Bundle\SyliusConsumerBundle\Tests\Unit\Entity;
1515

1616
use PHPUnit\Framework\TestCase;
17+
use Prophecy\PhpUnit\ProphecyTrait;
1718
use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface;
1819
use Sulu\Bundle\SyliusConsumerBundle\Entity\TaxonCategoryBridge;
1920

2021
class TaxonCategoryBridgeTest extends TestCase
2122
{
23+
use ProphecyTrait;
24+
2225
public function testGetId(): void
2326
{
2427
$category = $this->prophesize(CategoryInterface::class);

Tests/Unit/Handler/RemoveProductMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
namespace Sulu\Bundle\SyliusConsumerBundle\Tests\Unit\Handler;
1515

1616
use PHPUnit\Framework\TestCase;
17+
use Prophecy\PhpUnit\ProphecyTrait;
1718
use Sulu\Bundle\SyliusConsumerBundle\Adapter\ProductAdapterInterface;
1819
use Sulu\Bundle\SyliusConsumerBundle\Handler\RemoveProductMessageHandler;
1920
use Sulu\Bundle\SyliusConsumerBundle\Message\RemoveProductMessage;
2021

2122
class RemoveProductMessageHandlerTest extends TestCase
2223
{
24+
use ProphecyTrait;
25+
2326
public function testInvoke(): void
2427
{
2528
$adapter1 = $this->prophesize(ProductAdapterInterface::class);

Tests/Unit/Handler/RemoveProductVariantMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
namespace Sulu\Bundle\SyliusConsumerBundle\Tests\Unit\Handler;
1515

1616
use PHPUnit\Framework\TestCase;
17+
use Prophecy\PhpUnit\ProphecyTrait;
1718
use Sulu\Bundle\SyliusConsumerBundle\Adapter\ProductVariantAdapterInterface;
1819
use Sulu\Bundle\SyliusConsumerBundle\Handler\RemoveProductVariantMessageHandler;
1920
use Sulu\Bundle\SyliusConsumerBundle\Message\RemoveProductVariantMessage;
2021

2122
class RemoveProductVariantMessageHandlerTest extends TestCase
2223
{
24+
use ProphecyTrait;
25+
2326
public function testInvoke(): void
2427
{
2528
$adapter1 = $this->prophesize(ProductVariantAdapterInterface::class);

Tests/Unit/Handler/RemoveTaxonMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
namespace Sulu\Bundle\SyliusConsumerBundle\Tests\Unit\Handler;
1515

1616
use PHPUnit\Framework\TestCase;
17+
use Prophecy\PhpUnit\ProphecyTrait;
1718
use Sulu\Bundle\SyliusConsumerBundle\Adapter\TaxonAdapterInterface;
1819
use Sulu\Bundle\SyliusConsumerBundle\Handler\RemoveTaxonMessageHandler;
1920
use Sulu\Bundle\SyliusConsumerBundle\Message\RemoveTaxonMessage;
2021

2122
class RemoveTaxonMessageHandlerTest extends TestCase
2223
{
24+
use ProphecyTrait;
25+
2326
public function testInvoke(): void
2427
{
2528
$adapter1 = $this->prophesize(TaxonAdapterInterface::class);

Tests/Unit/Handler/SynchronizeImageMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515

1616
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Sulu\Bundle\SyliusConsumerBundle\Adapter\ImageAdapterInterface;
1920
use Sulu\Bundle\SyliusConsumerBundle\Handler\SynchronizeImageMessageHandler;
2021
use Sulu\Bundle\SyliusConsumerBundle\Message\SynchronizeImageMessage;
2122
use Sulu\Bundle\SyliusConsumerBundle\Payload\ImagePayload;
2223

2324
class SynchronizeImageMessageHandlerTest extends TestCase
2425
{
26+
use ProphecyTrait;
27+
2528
public function testInvoke(): void
2629
{
2730
$adapter1 = $this->prophesize(ImageAdapterInterface::class);

Tests/Unit/Handler/SynchronizeProductMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515

1616
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Sulu\Bundle\SyliusConsumerBundle\Adapter\ProductAdapterInterface;
1920
use Sulu\Bundle\SyliusConsumerBundle\Handler\SynchronizeProductMessageHandler;
2021
use Sulu\Bundle\SyliusConsumerBundle\Message\SynchronizeProductMessage;
2122
use Sulu\Bundle\SyliusConsumerBundle\Payload\ProductPayload;
2223

2324
class SynchronizeProductMessageHandlerTest extends TestCase
2425
{
26+
use ProphecyTrait;
27+
2528
public function testInvoke(): void
2629
{
2730
$adapter1 = $this->prophesize(ProductAdapterInterface::class);

Tests/Unit/Handler/SynchronizeProductVariantMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515

1616
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Sulu\Bundle\SyliusConsumerBundle\Adapter\ProductVariantAdapterInterface;
1920
use Sulu\Bundle\SyliusConsumerBundle\Handler\SynchronizeProductVariantMessageHandler;
2021
use Sulu\Bundle\SyliusConsumerBundle\Message\SynchronizeProductVariantMessage;
2122
use Sulu\Bundle\SyliusConsumerBundle\Payload\ProductVariantPayload;
2223

2324
class SynchronizeProductVariantMessageHandlerTest extends TestCase
2425
{
26+
use ProphecyTrait;
27+
2528
public function testInvoke(): void
2629
{
2730
$adapter1 = $this->prophesize(ProductVariantAdapterInterface::class);

Tests/Unit/Handler/SynchronizeTaxonsMessageHandlerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515

1616
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Sulu\Bundle\SyliusConsumerBundle\Adapter\TaxonAdapterInterface;
1920
use Sulu\Bundle\SyliusConsumerBundle\Handler\SynchronizeTaxonsMessageHandler;
2021
use Sulu\Bundle\SyliusConsumerBundle\Message\SynchronizeTaxonsMessage;
2122
use Sulu\Bundle\SyliusConsumerBundle\Payload\TaxonPayload;
2223

2324
class SynchronizeTaxonsMessageHandlerTest extends TestCase
2425
{
26+
use ProphecyTrait;
27+
2528
public function testInvoke(): void
2629
{
2730
$adapter1 = $this->prophesize(TaxonAdapterInterface::class);

composer.json

+17-15
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,33 @@
1212
"license": "MIT",
1313
"require": {
1414
"php": "^7.2|^8.0",
15-
"sulu/sulu": "^2.1 || 2.x-dev",
16-
"symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0",
17-
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0 || ^7.0",
18-
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0",
19-
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0 || ^7.0",
20-
"symfony/messenger": "^4.4 || ^5.0 || ^6.0 || ^7.0",
15+
"sulu/sulu": "^2.4 || 2.x-dev",
16+
"symfony/config": "^5.4 || ^6.0 || ^7.0",
17+
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
18+
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
19+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
20+
"symfony/messenger": "^5.4 || ^6.0 || ^7.0",
2121
"webmozart/assert": "^1.9"
2222
},
2323
"require-dev": {
24-
"php-cs-fixer/shim": "^3.9",
2524
"handcraftedinthealps/zendsearch": "^2.0",
2625
"jackalope/jackalope-doctrine-dbal": "^1.3.4|| ^2.0",
2726
"jangregor/phpstan-prophecy": "^1.0",
27+
"php-cs-fixer/shim": "^3.9",
2828
"phpspec/prophecy": "^1.15",
29+
"phpspec/prophecy-phpunit": "^2.0",
2930
"phpstan/phpstan": "^1.0",
3031
"phpstan/phpstan-doctrine": "^1.0",
3132
"phpstan/phpstan-symfony": "^1.0",
3233
"phpstan/phpstan-webmozart-assert": "^1.0",
33-
"phpunit/phpunit": "^8.2",
34-
"symfony/browser-kit": "^4.4 || ^5.0 || ^6.0 || ^7.0",
35-
"symfony/dotenv": "^4.4 || ^5.0 || ^6.0 || ^7.0",
36-
"symfony/error-handler": "^4.4 || ^5.0 || ^6.0 || ^7.0",
34+
"phpunit/phpunit": "^9.6.20 || ^10.5.28",
35+
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0",
36+
"symfony/dotenv": "^5.4 || ^6.0 || ^7.0",
37+
"symfony/error-handler": "^5.4 || ^6.0 || ^7.0",
3738
"symfony/monolog-bundle": "^3.3"
3839
},
3940
"conflict": {
40-
"symfony/dependency-injection": "4.1.8",
41-
"symfony/symfony": "4.2.7",
42-
"symfony/framework-bundle": "4.2.7"
41+
"dantleech/phpcr-migrations-bundle": "<1.3.0"
4342
},
4443
"config": {
4544
"sort-packages": true,
@@ -66,7 +65,10 @@
6665
"@php-cs"
6766
],
6867
"phpunit": "vendor/bin/phpunit",
69-
"phpstan": "vendor/bin/phpstan analyze -c ./phpstan.neon . -l 5",
68+
"phpstan": [
69+
"Tests/Application/console cache:warmup --env dev",
70+
"vendor/bin/phpstan analyze -c ./phpstan.neon"
71+
],
7072
"php-cs": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
7173
"php-cs-fix": "vendor/bin/php-cs-fixer fix"
7274
}

phpstan.neon

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ includes:
55
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
66

77
parameters:
8+
level: 5
89
paths:
910
- .
10-
excludes_analyse:
11+
excludePaths:
1112
- %currentWorkingDirectory%/DependencyInjection/Configuration.php
1213
- %currentWorkingDirectory%/EventSubscriber/AutoLoginSubscriber.php
1314
- %currentWorkingDirectory%/Middleware/EventMiddleware.php

0 commit comments

Comments
 (0)