Skip to content

Commit 4e289d0

Browse files
authored
refactor #28 Add support for Symfony 5.0 / PHP 7.4 (pamil)
This PR was merged into the 1.6-dev branch. Discussion ---------- Includes and closes #27, includes a bit of maintenance as well. BC breaks in commands, though it has really low impact and I'd be surprised if it breaks the application for any of end-users. Totally worth it (so we can add Symfony 5 support). Commits ------- d0113a9 Remove "zendframework/zend-stdlib" dependency b36dd74 Update dependencies to allow for Symfony 5 6cecb52 Apply coding standard fixes 8bb6b98 Improve Travis: PHP 7.4 support, Symfony 4.4 and 5.0 64ea901 Add an UPGRADE.md note about a BC break
2 parents 8c8359b + 64ea901 commit 4e289d0

22 files changed

+299
-157
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66

77
/phpspec.yml
88
/phpunit.xml
9+
/.phpunit.result.cache

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ language: php
33
php:
44
- 7.2
55
- 7.3
6+
- 7.4
67

78
env:
8-
- SYMFONY_VERSION=3.4.*
9-
- SYMFONY_VERSION=4.1.*
10-
- SYMFONY_VERSION=4.2.*
9+
- SYMFONY_VERSION=4.4.*
10+
- SYMFONY_VERSION=5.0.*
1111

1212
cache:
1313
directories:
@@ -26,5 +26,4 @@ script:
2626

2727
- composer analyse
2828

29-
- vendor/bin/phpspec run
30-
- vendor/bin/phpunit tests
29+
- composer test

UPGRADE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## UPGRADE FROM `1.5.x` TO `1.6`
2+
3+
- Commands `FixturesListCommand` and `FixturesLoadCommand` are not container aware anymore, they have dependencies
4+
injected through the constructor. Adjust your code if you've modified them or their DI definitions.

composer.json

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,19 @@
2424

2525
"doctrine/data-fixtures": "^1.2",
2626
"monolog/monolog": "^1.8",
27-
"symfony/framework-bundle": "^3.4|^4.1.1",
28-
"symfony/monolog-bridge": "^3.4|^4.1.1",
29-
"webmozart/assert": "^1.0",
30-
"zendframework/zend-stdlib": "^3.0"
27+
"symfony/framework-bundle": "^4.4|^5.0",
28+
"symfony/monolog-bridge": "^4.4|^5.0",
29+
"webmozart/assert": "^1.0"
3130
},
3231
"require-dev": {
33-
"doctrine/doctrine-bundle": "^1.3",
34-
"doctrine/orm": "^2.5",
35-
"matthiasnoback/symfony-config-test": "^4.0",
36-
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
37-
"phpspec/phpspec": "^5.0",
38-
"phpstan/phpstan-phpunit": "^0.10",
39-
"phpstan/phpstan-shim": "^0.10",
40-
"phpunit/phpunit": "^7.0",
41-
"proget-hq/phpstan-phpspec": "^0.1.1",
42-
"sylius-labs/coding-standard": "^3.0"
32+
"doctrine/doctrine-bundle": "^2.0",
33+
"doctrine/orm": "^2.7",
34+
"matthiasnoback/symfony-config-test": "^4.2",
35+
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
36+
"phpspec/phpspec": "^6.1",
37+
"phpunit/phpunit": "^8.5",
38+
"sylius-labs/coding-standard": "^3.1",
39+
"vimeo/psalm": "3.11.4"
4340
},
4441
"autoload": {
4542
"psr-4": { "Sylius\\Bundle\\FixturesBundle\\": "src/" }
@@ -52,7 +49,15 @@
5249
},
5350
"scripts": {
5451
"analyse": [
55-
"@php vendor/bin/phpstan analyse --ansi -c phpstan.neon -l max spec src tests"
52+
"vendor/bin/ecs check spec src tests",
53+
"vendor/bin/psalm"
54+
],
55+
"fix": [
56+
"vendor/bin/ecs check spec src tests --fix"
57+
],
58+
"test": [
59+
"vendor/bin/phpspec run --ansi --no-interaction",
60+
"vendor/bin/phpunit --colors=always"
5661
]
5762
},
5863
"extra": {

easy-coding-standard.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
imports:
22
- { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' }
33

4+
parameters:
5+
exclude_files:
6+
- '**/var/*'
7+
48
services:
59
PhpCsFixer\Fixer\Comment\HeaderCommentFixer:
610
header: |

phpstan.neon

Lines changed: 0 additions & 15 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
colors="true"
66
>
77
<php>
8+
<ini name="error_reporting" value="-1" />
9+
810
<env name="KERNEL_CLASS" value="Sylius\Bundle\FixturesBundle\Tests\Application\Kernel" />
11+
12+
<server name="SHELL_VERBOSITY" value="-1" />
913
</php>
1014

1115
<testsuites>

psalm.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="2"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
<file name="src/Listener/MongoDBPurgerListener.php" />
14+
<file name="src/Listener/PHPCRPurgerListener.php" />
15+
</ignoreFiles>
16+
</projectFiles>
17+
</psalm>

spec/Suite/PriorityQueueSpec.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Paweł Jędrzejewski
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace spec\Sylius\Bundle\FixturesBundle\Suite;
15+
16+
use PhpSpec\ObjectBehavior;
17+
use Sylius\Bundle\FixturesBundle\Suite\PriorityQueue;
18+
19+
final class PriorityQueueSpec extends ObjectBehavior
20+
{
21+
function it_is_initializable(): void
22+
{
23+
$this->shouldHaveType(PriorityQueue::class);
24+
}
25+
26+
function it_keeps_fifo_order_for_elements_with_same_priority(): void
27+
{
28+
$this->insert(['element' => 1]);
29+
$this->insert(['element' => 2]);
30+
31+
$this->getIterator()->shouldIterateAs([['element' => 1], ['element' => 2]]);
32+
}
33+
34+
function it_sorts_elements_by_their_priority(): void
35+
{
36+
$this->insert(['element' => 3], -1);
37+
$this->insert(['element' => 2], 0);
38+
$this->insert(['element' => 1], 1);
39+
40+
$this->getIterator()->shouldIterateAs([['element' => 1], ['element' => 2], ['element' => 3]]);
41+
}
42+
}

src/Command/FixturesListCommand.php

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,26 @@
1515

1616
use Sylius\Bundle\FixturesBundle\Fixture\FixtureRegistryInterface;
1717
use Sylius\Bundle\FixturesBundle\Suite\SuiteRegistryInterface;
18-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
18+
use Symfony\Component\Console\Command\Command;
1919
use Symfony\Component\Console\Input\InputInterface;
2020
use Symfony\Component\Console\Output\OutputInterface;
2121

22-
final class FixturesListCommand extends ContainerAwareCommand
22+
final class FixturesListCommand extends Command
2323
{
24+
/** @var SuiteRegistryInterface */
25+
private $suiteRegistry;
26+
27+
/** @var FixtureRegistryInterface */
28+
private $fixtureRegistry;
29+
30+
public function __construct(SuiteRegistryInterface $suiteRegistry, FixtureRegistryInterface $fixtureRegistry)
31+
{
32+
parent::__construct(null);
33+
34+
$this->suiteRegistry = $suiteRegistry;
35+
$this->fixtureRegistry = $fixtureRegistry;
36+
}
37+
2438
/**
2539
* {@inheritdoc}
2640
*/
@@ -35,15 +49,17 @@ protected function configure(): void
3549
/**
3650
* {@inheritdoc}
3751
*/
38-
protected function execute(InputInterface $input, OutputInterface $output): void
52+
protected function execute(InputInterface $input, OutputInterface $output): int
3953
{
4054
$this->listSuites($output);
4155
$this->listFixtures($output);
56+
57+
return 0;
4258
}
4359

4460
private function listSuites(OutputInterface $output): void
4561
{
46-
$suites = $this->getSuiteRegistry()->getSuites();
62+
$suites = $this->suiteRegistry->getSuites();
4763

4864
$output->writeln('Available suites:');
4965

@@ -54,30 +70,12 @@ private function listSuites(OutputInterface $output): void
5470

5571
private function listFixtures(OutputInterface $output): void
5672
{
57-
$fixtures = $this->getFixtureRegistry()->getFixtures();
73+
$fixtures = $this->fixtureRegistry->getFixtures();
5874

5975
$output->writeln('Available fixtures:');
6076

6177
foreach ($fixtures as $name => $fixture) {
6278
$output->writeln(' - ' . $name);
6379
}
6480
}
65-
66-
private function getSuiteRegistry(): SuiteRegistryInterface
67-
{
68-
$suiteRegistry = $this->getContainer()->get('sylius_fixtures.suite_registry');
69-
70-
assert($suiteRegistry instanceof SuiteRegistryInterface);
71-
72-
return $suiteRegistry;
73-
}
74-
75-
private function getFixtureRegistry(): FixtureRegistryInterface
76-
{
77-
$fixtureRegistry = $this->getContainer()->get('sylius_fixtures.fixture_registry');
78-
79-
assert($fixtureRegistry instanceof FixtureRegistryInterface);
80-
81-
return $fixtureRegistry;
82-
}
8381
}

0 commit comments

Comments
 (0)