Skip to content

Commit 194abb3

Browse files
committed
⬆️ allow Symfony 6
1 parent 654b105 commit 194abb3

File tree

7 files changed

+60
-65
lines changed

7 files changed

+60
-65
lines changed

.github/workflows/build.yaml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@ jobs:
2929
runs-on: ubuntu-20.04
3030
strategy:
3131
matrix:
32-
php:
33-
- '7.3'
34-
- '7.4'
35-
- '8.0'
3632
include:
3733
- description: 'Symfony 4.4'
38-
php: '7.3'
34+
php: '7.4'
35+
symfony: '4.4.*'
3936
composer_option: '--prefer-lowest'
40-
- description: 'Symfony 5.1'
37+
- description: 'Symfony 5.3'
4138
php: '7.4'
42-
symfony: 5.1.*
43-
- description: 'Symfony 5.2'
39+
symfony: '5.3.*'
40+
- description: 'Symfony 5.4'
4441
php: '8.0'
45-
symfony: 5.2.*
42+
symfony: '5.4.*@dev'
4643
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
4744
steps:
4845
- name: Checkout
@@ -56,13 +53,26 @@ jobs:
5653
uses: shivammathur/setup-php@v2
5754
with:
5855
php-version: ${{ matrix.php }}
59-
- run: |
60-
sed -ri '/symfony\/swiftmailer-bundle/! s/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json;
56+
- name: require specific Symfony version
6157
if: matrix.symfony
62-
- run: composer require --dev doctrine/lexer:v1.0.1 --no-update
63-
if: matrix.composer_option == '--prefer-lowest'
64-
- run: composer update --no-interaction --no-progress --ansi ${{ matrix.composer_option }}
65-
- run: bin/phpunit --coverage-clover=clover.xml
66-
- uses: codecov/codecov-action@v1
58+
run: |
59+
sed -ri '/symfony\/swiftmailer-bundle/! s/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json;
60+
composer require --dev doctrine/lexer:v1.0.1 --no-update
61+
- name: use possible dev deps
62+
if: contains(matrix.symfony, '@dev')
63+
run: |
64+
composer config minimum-stability dev
65+
composer config prefer-stable true
66+
- name: remove cs-fixer for Symfony 6
67+
if: contains(matrix.symfony, '6.0.*@dev')
68+
run: |
69+
composer remove --dev friendsofphp/php-cs-fixer --no-update
70+
composer remove --dev symfony/swiftmailer-bundle --no-update
71+
- name: update vendors
72+
run: composer update --no-interaction --no-progress --ansi ${{ matrix.composer_option }}
73+
- name: run tests
74+
run: bin/phpunit --coverage-clover=clover.xml
75+
- name: save test coverage
76+
uses: codecov/codecov-action@v1
6777
with:
6878
files: ./clover.xml

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^7.3 || ^8.0",
18+
"php": "^7.4 || ^8.0",
1919
"doctrine/data-fixtures": "^1.5",
20-
"symfony/browser-kit": "^4.4 || ^5.0",
21-
"symfony/console": "^4.4 || ^5.0",
22-
"symfony/css-selector": "^4.4 || ^5.0",
23-
"symfony/dependency-injection": "^4.4 || ^5.0",
24-
"symfony/dom-crawler": "^4.4 || ^5.0"
20+
"symfony/browser-kit": "^4.4 || ^5.0 || ^6.0",
21+
"symfony/console": "^4.4 || ^5.0 || ^6.0",
22+
"symfony/css-selector": "^4.4 || ^5.0 || ^6.0",
23+
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
24+
"symfony/dom-crawler": "^4.4 || ^5.0 || ^6.0"
2525
},
2626
"require-dev": {
2727
"doctrine/lexer": "^1.2",
2828
"doctrine/orm": "^2.8",
29-
"friendsofphp/php-cs-fixer": "^2.18",
29+
"friendsofphp/php-cs-fixer": "^3.0",
3030
"mikey179/vfsstream": "^1.6",
3131
"phpunit/phpunit": "^9.5",
3232
"symfony/doctrine-bridge": "^4.4 || ^5.0",

phpstan-baseline.neon

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ parameters:
66
path: src/DependencyInjection/Configuration.php
77

88
-
9-
message: "#^Parameter \\$manager of method Beelab\\\\TestBundle\\\\Tests\\\\FakeFixture\\:\\:load\\(\\) has invalid typehint type Doctrine\\\\Common\\\\Persistence\\\\ObjectManager\\.$#"
9+
message: "#^PHPDoc tag @throws with type Doctrine\\\\DBAL\\\\DBALException\\|InvalidArgumentException is not subtype of Throwable$#"
1010
count: 1
11-
path: tests/FakeFixture.php
12-
13-
-
14-
message: "#^Parameter \\$manager of method Beelab\\\\TestBundle\\\\Tests\\\\FakeFixtureDependent\\:\\:load\\(\\) has invalid typehint type Doctrine\\\\Common\\\\Persistence\\\\ObjectManager\\.$#"
15-
count: 1
16-
path: tests/FakeFixtureDependent.php
11+
path: src/Test/WebTestCase.php
1712

src/DataFixtures/AbstractContainerAwareFixture.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
*/
1212
abstract class AbstractContainerAwareFixture extends AbstractFixture implements ContainerAwareInterface
1313
{
14-
/**
15-
* @var ContainerInterface
16-
*/
17-
protected $container;
14+
protected ContainerInterface $container;
1815

1916
public function setContainer(ContainerInterface $container = null): void
2017
{

src/Test/WebTestCase.php

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
namespace Beelab\TestBundle\Test;
44

5+
use Doctrine\Common\DataFixtures\AbstractFixture;
6+
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
57
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
68
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
79
use Doctrine\ORM\EntityManagerInterface;
810
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader as Loader;
911
use Symfony\Bundle\FrameworkBundle\Console\Application;
12+
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1013
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase;
1114
use Symfony\Component\BrowserKit\Cookie;
1215
use Symfony\Component\Console\Command\Command;
@@ -21,30 +24,15 @@
2124

2225
abstract class WebTestCase extends SymfonyWebTestCase
2326
{
24-
/**
25-
* @var EntityManagerInterface|null
26-
*/
27-
protected static $em;
27+
protected static ?EntityManagerInterface $em = null;
2828

29-
/**
30-
* @var \Symfony\Bundle\FrameworkBundle\KernelBrowser
31-
*/
32-
protected static $client;
29+
protected static ?KernelBrowser $client = null;
3330

34-
/**
35-
* @var \Doctrine\Common\DataFixtures\AbstractFixture|null
36-
*/
37-
private $fixture;
31+
private ?AbstractFixture $fixture = null;
3832

39-
/**
40-
* @var string|null
41-
*/
42-
protected static $authUser;
33+
protected static ?string $authUser = null;
4334

44-
/**
45-
* @var string|null
46-
*/
47-
protected static $authPw;
35+
protected static ?string $authPw = null;
4836

4937
protected function setUp(): void
5038
{
@@ -221,13 +209,15 @@ protected function loadFixtures(
221209
*/
222210
protected static function assertMailSent(int $num, string $message = ''): void
223211
{
224-
if (false !== $profile = self::$client->getProfile()) {
225-
/** @var \Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector $collector */
226-
$collector = $profile->getCollector('swiftmailer');
227-
self::assertEquals($num, $collector->getMessageCount(), $message);
228-
} else {
212+
if (false === $profile = self::$client->getProfile()) {
229213
self::markTestSkipped('Profiler not enabled.');
230214
}
215+
/** @var \Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector|null $collector */
216+
$collector = $profile->getCollector('swiftmailer');
217+
if (null === $collector) {
218+
self::markTestSkipped('Swiftmailer profiler not found.');
219+
}
220+
self::assertEquals($num, $collector->getMessageCount(), $message);
231221
}
232222

233223
/**
@@ -288,6 +278,9 @@ protected function getReference(string $name)
288278
if (null === $this->fixture) {
289279
throw new \RuntimeException('Load some fixtures before.');
290280
}
281+
if (!$this->fixture instanceof DependentFixtureInterface) {
282+
throw new \RuntimeException('Fixture is not dependent.');
283+
}
291284
if (!$this->fixture->hasReference($name)) {
292285
throw new \InvalidArgumentException(\sprintf('Reference "%s" not found.', $name));
293286
}

tests/FakeFixture.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace Beelab\TestBundle\Tests;
44

5-
use Doctrine\Common\DataFixtures\FixtureInterface;
5+
use Doctrine\Common\DataFixtures\AbstractFixture;
66
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
77
use Doctrine\Persistence\ObjectManager;
88

99
if (\interface_exists(LegacyObjectManager::class)) {
10-
final class FakeFixture implements FixtureInterface
10+
final class FakeFixture extends AbstractFixture
1111
{
1212
public function load(LegacyObjectManager $manager): void
1313
{
1414
}
1515
}
1616
} else {
17-
final class FakeFixture implements FixtureInterface
17+
final class FakeFixture extends AbstractFixture
1818
{
1919
public function load(ObjectManager $manager): void
2020
{

tests/FakeFixtureDependent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Beelab\TestBundle\Tests;
44

5+
use Doctrine\Common\DataFixtures\AbstractFixture;
56
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
6-
use Doctrine\Common\DataFixtures\FixtureInterface;
77
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
88
use Doctrine\Persistence\ObjectManager;
99

1010
if (\interface_exists(LegacyObjectManager::class)) {
11-
final class FakeFixtureDependent implements DependentFixtureInterface, FixtureInterface
11+
final class FakeFixtureDependent extends AbstractFixture implements DependentFixtureInterface
1212
{
1313
public function getDependencies(): array
1414
{
@@ -23,7 +23,7 @@ public function load(LegacyObjectManager $manager)
2323
}
2424
}
2525
} else {
26-
final class FakeFixtureDependent implements DependentFixtureInterface, FixtureInterface
26+
final class FakeFixtureDependent extends AbstractFixture implements DependentFixtureInterface
2727
{
2828
public function getDependencies(): array
2929
{

0 commit comments

Comments
 (0)