Skip to content

Commit

Permalink
Drop support of Symfony < 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Feb 18, 2021
1 parent 0006751 commit 12dfa7d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 64 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
include:
- php-version: 7.2
composer-flags: "--prefer-lowest"
- php-version: 7.2
symfony-version: "^3.4"
- php-version: 7.2
symfony-version: "^4.4"
- php-version: 7.3
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ matrix:
include:
- php: 7.2
env: COMPOSER_FLAGS="--prefer-lowest"
- php: 7.2
env: SYMFONY_VERSION="^3.4"
- php: 7.2
env: SYMFONY_VERSION="^4.4"
- php: 7.3
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"require": {
"php": "^7.2 || ^8.0",
"doctrine/common": "^2.13 || ^3.0",
"symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.0",
"symfony/event-dispatcher": "^4.4 || ^5.0",
"symfony/event-dispatcher-contracts": "^1 || ^2",
"symfony/framework-bundle": "^3.4 || ^4.4 || ^5.0",
"symfony/yaml": "^3.4 || ^4.4 || ^5.0"
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/yaml": "^4.4 || ^5.0"
},
"require-dev": {
"doctrine/data-fixtures": "^1.3",
Expand All @@ -34,7 +34,7 @@
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/monolog-bridge": ">=3",
"symfony/monolog-bundle": "^3.2",
"symfony/phpunit-bridge": "^3.4 || ^4.4 || ^5.0",
"symfony/phpunit-bridge": "^4.4 || ^5.0",
"theofidry/alice-data-fixtures": "^1.0.1"
},
"suggest": {
Expand Down
12 changes: 0 additions & 12 deletions doc/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ Tips for Fixture Loading Tests
test-environment to use a SQLite-database. This will make your tests run
faster and will create a fresh, predictable database for every test you run.

* For symfony 3: add those lines to `app/config/config_test.yml`:
```yaml
# app/config/config_test.yml
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
path: "%kernel.cache_dir%/test.db"
```

* For symfony 4 : create file if it doesn't exists `config/packages/test/doctrine.yaml`, and if it does append those lines:
```yaml
# config/packages/test/doctrine.yaml
Expand Down
10 changes: 2 additions & 8 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('liip_test_fixtures');
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('liip_test_fixtures', 'array');
}
$treeBuilder = new TreeBuilder('liip_test_fixtures');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
18 changes: 0 additions & 18 deletions src/Services/DatabaseTools/AbstractDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,4 @@ protected function getCacheMetadataParameter()
return $this->container->hasParameter(self::CACHE_METADATA_PARAMETER_NAME)
&& false !== $this->container->getParameter(self::CACHE_METADATA_PARAMETER_NAME);
}

/**
* Compatibility layer for Symfony <= 4.3
*
* @see https://github.com/symfony/symfony/blob/75369dabb8af73b0d0ad7f206d85c08cf39117f8/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php#L30-L35
*/
protected function dispatchEvent(FixtureEvent $event, $eventName) {
$r = new ReflectionMethod($this->eventDispatcher, 'dispatch');
$param2 = $r->getParameters()[1] ?? null;

if (!$param2 || !$param2->hasType() || $param2->getType()->isBuiltin()) {
$this->eventDispatcher->dispatch($event, $eventName);

return;
}

$this->eventDispatcher->dispatch($eventName, $event);
}
}
8 changes: 4 additions & 4 deletions src/Services/DatabaseTools/MongoDBDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
$this->om->clear();

$event = new PreFixtureBackupRestoreEvent($this->om, $referenceRepository, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);

$executor = $this->getExecutor($this->getPurger());
$executor->setReferenceRepository($referenceRepository);
$backupService->restore($executor);

$event = new PostFixtureBackupRestoreEvent($backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);

return $executor;
}
Expand All @@ -96,12 +96,12 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst

if ($backupService) {
$event = new ReferenceSaveEvent($this->om, $executor, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);
$this->testCase->preReferenceSave($this->om, $executor, $backupService->getBackupFilePath());

$backupService->backup($executor);

$this->dispatchEvent($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
$this->testCase->postReferenceSave($this->om, $executor, $backupService->getBackupFilePath());
}

Expand Down
10 changes: 5 additions & 5 deletions src/Services/DatabaseTools/ORMDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
$this->om->clear();

$event = new PreFixtureBackupRestoreEvent($this->om, $referenceRepository, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);

$executor = $this->getExecutor($this->getPurger());
$executor->setReferenceRepository($referenceRepository);
$backupService->restore($executor, $this->excludedDoctrineTables);

$event = new PostFixtureBackupRestoreEvent($backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);

return $executor;
}
Expand All @@ -151,7 +151,7 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
}

$event = new FixtureEvent();
$this->dispatchEvent($event, LiipTestFixturesEvents::POST_FIXTURE_SETUP);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_FIXTURE_SETUP);

$executor = $this->getExecutor($this->getPurger());
$executor->setReferenceRepository($referenceRepository);
Expand All @@ -166,11 +166,11 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst

if ($backupService) {
$event = new ReferenceSaveEvent($this->om, $executor, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);

$backupService->backup($executor);

$this->dispatchEvent($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
}

return $executor;
Expand Down
10 changes: 5 additions & 5 deletions src/Services/DatabaseTools/ORMSqliteDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
$this->om->clear();

$event = new PreFixtureBackupRestoreEvent($this->om, $referenceRepository, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);

$executor = $this->getExecutor($this->getPurger());
$executor->setReferenceRepository($referenceRepository);
$backupService->restore($executor);

$event = new PostFixtureBackupRestoreEvent($backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);

return $executor;
}
Expand All @@ -81,7 +81,7 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
}

$event = new FixtureEvent();
$this->dispatchEvent($event, LiipTestFixturesEvents::POST_FIXTURE_SETUP);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_FIXTURE_SETUP);

$executor = $this->getExecutor($this->getPurger());
$executor->setReferenceRepository($referenceRepository);
Expand All @@ -94,11 +94,11 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst

if ($backupService) {
$event = new ReferenceSaveEvent($this->om, $executor, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);

$backupService->backup($executor);

$this->dispatchEvent($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
}

return $executor;
Expand Down
8 changes: 4 additions & 4 deletions src/Services/DatabaseTools/PHPCRDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
$this->om->clear();

$event = new PreFixtureBackupRestoreEvent($this->om, $referenceRepository, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE);

$executor = $this->getExecutor($this->getPurger());
$executor->setReferenceRepository($referenceRepository);
$backupService->restore($executor);

$event = new PostFixtureBackupRestoreEvent($backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE);

return $executor;
}
Expand All @@ -103,11 +103,11 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst

if ($backupService) {
$event = new ReferenceSaveEvent($this->om, $executor, $backupService->getBackupFilePath());
$this->dispatchEvent($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::PRE_REFERENCE_SAVE);

$backupService->backup($executor);

$this->dispatchEvent($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
$this->eventDispatcher->dispatch($event, LiipTestFixturesEvents::POST_REFERENCE_SAVE);
}

return $executor;
Expand Down

0 comments on commit 12dfa7d

Please sign in to comment.