-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for doctrine/data-fixtures 2.0
- Loading branch information
Showing
7 changed files
with
27 additions
and
16 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
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 |
---|---|---|
|
@@ -28,14 +28,14 @@ public function load(ObjectManager $manager): void | |
|
||
$manager->persist($user); | ||
|
||
$this->addReference('user', $user); | ||
|
||
$user = new User(); | ||
$user->setId(2); | ||
$user->setName('bob bar'); | ||
$user->setEmail('[email protected]'); | ||
$user2 = new User(); | ||
$user2->setId(2); | ||
$user2->setName('bob bar'); | ||
$user2->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->persist($user2); | ||
$manager->flush(); | ||
|
||
$this->addReference('user', $user); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -33,13 +33,13 @@ public function load(ObjectManager $manager): void | |
|
||
$manager->persist($user); | ||
|
||
$this->addReference('user', $user); | ||
|
||
$user2 = new User(); | ||
$user2->setName('alice bar'); | ||
$user2->setEmail('[email protected]'); | ||
|
||
$manager->persist($user2); | ||
$manager->flush(); | ||
|
||
$this->addReference('user', $user); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
use Composer\InstalledVersions; | ||
use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle; | ||
use Doctrine\Common\DataFixtures\Executor\MongoDBExecutor; | ||
use Doctrine\Common\DataFixtures\ProxyReferenceRepository; | ||
|
@@ -61,6 +62,16 @@ protected function setUp(): void | |
$this->markTestSkipped('Need doctrine/mongodb-odm-bundle package.'); | ||
} | ||
|
||
// `doctrine/data-fixtures:^2.0` and `doctrine/mongodb-odm-bundle:^4.4` are not compatible | ||
if (class_exists(InstalledVersions::class)) { | ||
$fixturesVersion = InstalledVersions::getVersion('doctrine/data-fixtures'); | ||
$bundleVersion = InstalledVersions::getVersion('doctrine/mongodb-odm-bundle'); | ||
|
||
if (null !== $fixturesVersion && null !== $bundleVersion && version_compare($fixturesVersion, '2.0', '>=') && version_compare($bundleVersion, '5.0', '<')) { | ||
$this->markTestSkipped(sprintf('The installed versions of doctrine/data-fixtures (%s) and doctrine/mongodb-odm-bundle (%s) are not compatible.', $fixturesVersion, $bundleVersion)); | ||
} | ||
} | ||
|
||
parent::setUp(); | ||
|
||
self::bootKernel([ | ||
|
@@ -93,7 +104,7 @@ public function testLoadFixturesMongodb(): void | |
$repository | ||
); | ||
|
||
$user1 = $repository->getReference('user'); | ||
$user1 = $repository->getReference('user', User::class); | ||
|
||
$this->assertSame('foo bar', $user1->getName()); | ||
$this->assertSame('[email protected]', $user1->getEmail()); | ||
|
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 |
---|---|---|
|
@@ -93,7 +93,7 @@ public function testLoadFixtures(): void | |
$repository | ||
); | ||
|
||
$user1 = $repository->getReference('user'); | ||
$user1 = $repository->getReference('user', User::class); | ||
|
||
$this->assertSame('foo bar', $user1->getName()); | ||
$this->assertSame('[email protected]', $user1->getEmail()); | ||
|
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