Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for doctrine/data-fixtures 2.0 #326

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
mbabker marked this conversation as resolved.
Show resolved Hide resolved
symfony-version: "^7.1"
symfony-version: "^7.2"

services:
mariadb:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions tests/App/DataFixtures/ORM/LoadUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
13 changes: 12 additions & 1 deletion tests/Test/ConfigMongodbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/ConfigMysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/ConfigSqliteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading