-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically extract fixture dependencies
It is now no longer required to declare groups on all dependent fixtures, the fixture loader will now automatically find the required dependencies and load them without them being explicitly added to the groups being loaded. Before you were forced to declare groups all the way down the dependency chain, for example: ``` TopLevelFixture (groups: default) ├─ SecondLevelFixture1 (groups: default, alternative) │ ├─ ThirdLevelFixture1 (groups: default, alternative) ├─ SecondLevelFixture2 (groups: default) │ ├─ ThridLevelFixture2 (groups: default) │ ├─ ThirdLevelFixture3 (groups: default, alternative) ``` Now you only need to specify the groups at the highest level: ``` TopLevelFixture (groups: default) ├─ SecondLevelFixture1 (groups: alternative) │ ├─ ThirdLevelFixture1 (groups: none) ├─ SecondLevelFixture2 (groups: none) │ ├─ ThridLevelFixture2 (groups: none) │ ├─ ThirdLevelFixture3 (groups: alternative) ``` In both examples the groups `default` and `alternative` will load the same fixtures. Adds an additional PHPStan error to the baseline which appears to be caused by the backwards compatibility layer.
- Loading branch information
Showing
5 changed files
with
82 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/Fixtures/FooBundle/DataFixtures/WithDeepDependenciesFixtures.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures; | ||
|
||
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; | ||
use Doctrine\Bundle\FixturesBundle\ORMFixtureInterface; | ||
use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||
use Doctrine\Persistence\ObjectManager; | ||
|
||
class WithDeepDependenciesFixtures implements ORMFixtureInterface, DependentFixtureInterface, FixtureGroupInterface | ||
{ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
// ... | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getDependencies(): array | ||
{ | ||
return [WithDependenciesFixtures::class, DependentOnRequiredConstructorArgsFixtures::class]; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public static function getGroups(): array | ||
{ | ||
return ['groupWithDeepDependencies']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters