Skip to content

Commit

Permalink
Add support for doctrine/data-fixtures 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Dec 2, 2024
1 parent 537bcb4 commit ab5709f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
symfony-version: "^7.1"
- php-version: 8.4
symfony-version: "^7.1"
- php-version: 8.4
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",
"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);
}
}
2 changes: 1 addition & 1 deletion tests/Test/ConfigMongodbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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

0 comments on commit ab5709f

Please sign in to comment.