diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index df34d00..347bcee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,11 +30,11 @@ jobs: # add a specific job to test mysqldump from MariaDB mysql-client: "mariadb-client" - php-version: 8.2 - symfony-version: "^7.1" + symfony-version: "^7.2" - php-version: 8.3 - symfony-version: "^7.1" + symfony-version: "^7.2" - php-version: 8.4 - symfony-version: "^7.1" + symfony-version: "^7.2" services: mariadb: diff --git a/composer.json b/composer.json index 2b39a75..27b9b77 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "symfony/yaml": "^5.4 || ^6.3 || ^7.0" }, "require-dev": { - "doctrine/data-fixtures": "^1.7", + "doctrine/data-fixtures": "^1.7 || ^2.0.1", "doctrine/doctrine-bundle": "^2.11", "doctrine/doctrine-fixtures-bundle": "^3.5.1 || ^4.0", "doctrine/mongodb-odm-bundle": "^4.4 || ^5.0", diff --git a/tests/App/DataFixtures/ORM/LoadUserData.php b/tests/App/DataFixtures/ORM/LoadUserData.php index 2670829..31fcd9e 100644 --- a/tests/App/DataFixtures/ORM/LoadUserData.php +++ b/tests/App/DataFixtures/ORM/LoadUserData.php @@ -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('bob@bar.com'); + $user2 = new User(); + $user2->setId(2); + $user2->setName('bob bar'); + $user2->setEmail('bob@bar.com'); - $manager->persist($user); + $manager->persist($user2); $manager->flush(); + + $this->addReference('user', $user); } } diff --git a/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php b/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php index a16dd1e..e23c4b3 100755 --- a/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php +++ b/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php @@ -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('alice@bar.com'); $manager->persist($user2); $manager->flush(); + + $this->addReference('user', $user); } } diff --git a/tests/Test/ConfigMongodbTest.php b/tests/Test/ConfigMongodbTest.php index a2a7a65..696b961 100755 --- a/tests/Test/ConfigMongodbTest.php +++ b/tests/Test/ConfigMongodbTest.php @@ -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('foo@bar.com', $user1->getEmail()); diff --git a/tests/Test/ConfigMysqlTest.php b/tests/Test/ConfigMysqlTest.php index 11bb2c0..ee4e1bc 100644 --- a/tests/Test/ConfigMysqlTest.php +++ b/tests/Test/ConfigMysqlTest.php @@ -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('foo@bar.com', $user1->getEmail()); diff --git a/tests/Test/ConfigSqliteTest.php b/tests/Test/ConfigSqliteTest.php index 8f5b756..3837dca 100644 --- a/tests/Test/ConfigSqliteTest.php +++ b/tests/Test/ConfigSqliteTest.php @@ -97,7 +97,7 @@ public function testLoadFixtures(): void ); /** @var User $user1 */ - $user1 = $repository->getReference('user'); + $user1 = $repository->getReference('user', User::class); $this->assertSame(1, $user1->getId()); $this->assertSame('foo bar', $user1->getName());