-
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.
Merge branch '2.x' into chore-merge-2.x-in-3.x
# Conflicts: # .github/workflows/tests.yml # composer.json # doc/contributing.md # tests/Test/ConfigMysqlCacheDbTest.php # tests/Test/ConfigMysqlTest.php # tests/Test/ConfigTest.php
- Loading branch information
Showing
14 changed files
with
163 additions
and
49 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 |
---|---|---|
|
@@ -22,17 +22,18 @@ class LoadDependentUserData extends AbstractFixture implements DependentFixtureI | |
{ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
/** @var User $user */ | ||
$user = clone $this->getReference('user'); | ||
|
||
$user = new User(); | ||
$user->setId(3); | ||
$user->setName('alice bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
||
$user = clone $this->getReference('user'); | ||
|
||
$user = new User(); | ||
$user->setId(4); | ||
$user->setName('eve bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
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 |
---|---|---|
|
@@ -31,18 +31,19 @@ public function __construct(DummyService $dummyService) | |
|
||
public function load(ObjectManager $manager): void | ||
{ | ||
/** @var User $user */ | ||
$user = clone $this->getReference('serviceUser'); | ||
|
||
$user = new User(); | ||
$user->setId(3); | ||
$user->setName('alice bar'); | ||
$user->setEmail('[email protected]'); | ||
$user->setDummyText($this->dummyService->getText()); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
||
$user = clone $this->getReference('serviceUser'); | ||
|
||
$user = new User(); | ||
$user->setId(4); | ||
$user->setName('eve bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
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,8 +22,9 @@ class LoadSecondUserData extends AbstractFixture | |
public function load(ObjectManager $manager): void | ||
{ | ||
$user = new User(); | ||
$user->setName('bar foo'); | ||
$user->setEmail('[email protected]'); | ||
$user->setId(3); | ||
$user->setName('alice bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
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 |
---|---|---|
|
@@ -31,9 +31,10 @@ public function load(ObjectManager $manager): void | |
|
||
$this->addReference('user', $user); | ||
|
||
$user = clone $this->getReference('user'); | ||
|
||
$user = new User(); | ||
$user->setId(2); | ||
$user->setName('bob bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
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,18 +33,18 @@ public function load(ObjectManager $manager): void | |
$manager->persist($user); | ||
$manager->flush(); | ||
|
||
$this->addReference('groupUser', $user); | ||
|
||
$user = clone $this->getReference('groupUser'); | ||
|
||
$user = new User(); | ||
$user->setId(2); | ||
$user->setName('bob bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
||
$user = clone $this->getReference('groupUser'); | ||
|
||
$user = new User(); | ||
$user->setId(3); | ||
$user->setName('alice bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
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 |
---|---|---|
|
@@ -42,11 +42,10 @@ public function load(ObjectManager $manager): void | |
$manager->persist($user); | ||
$manager->flush(); | ||
|
||
$this->addReference('serviceUser', $user); | ||
|
||
$user = clone $this->getReference('serviceUser'); | ||
|
||
$user = new User(); | ||
$user->setId(2); | ||
$user->setName('bob bar'); | ||
$user->setEmail('[email protected]'); | ||
|
||
$manager->persist($user); | ||
$manager->flush(); | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Liip\Acme\Tests\App\Entity\User: | ||
id{1..10}: | ||
user_id_{1..10}: | ||
id: <current()> | ||
name: <name()> | ||
email: <email()> |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Liip\Acme\Tests\App\Entity\User: | ||
id{1..10}: | ||
custom_user_id_{11..20}: | ||
id: <current()> | ||
name: <foo('a string')> | ||
email: <email()> |
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 |
---|---|---|
|
@@ -74,7 +74,7 @@ public function testLoadEmptyFixtures(): void | |
); | ||
} | ||
|
||
public function testLoadFixtures(int $firstUserId = 1): void | ||
public function testLoadFixtures(): void | ||
{ | ||
$fixtures = $this->databaseTool->loadFixtures([ | ||
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData', | ||
|
@@ -111,7 +111,7 @@ public function testLoadFixtures(int $firstUserId = 1): void | |
); | ||
} | ||
|
||
public function testAppendFixtures(int $firstUserId = 1, int $thirdUserId = 3): void | ||
public function testAppendFixtures(): void | ||
{ | ||
$this->databaseTool->loadFixtures([ | ||
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData', | ||
|
@@ -145,17 +145,31 @@ public function testAppendFixtures(int $firstUserId = 1, int $thirdUserId = 3): | |
$user1->getEmail() | ||
); | ||
|
||
/** @var User $user */ | ||
/** @var User $user2 */ | ||
$user2 = $this->userRepository | ||
->findOneBy([ | ||
'email' => '[email protected]', | ||
]) | ||
; | ||
|
||
$this->assertNotNull($user2); | ||
|
||
$this->assertSame( | ||
'[email protected]', | ||
$user2->getEmail() | ||
); | ||
|
||
/** @var User $user3 */ | ||
$user3 = $this->userRepository | ||
->findOneBy([ | ||
'email' => 'bar@foo.com', | ||
'email' => 'alice@bar.com', | ||
]) | ||
; | ||
|
||
$this->assertNotNull($user3); | ||
|
||
$this->assertSame( | ||
'bar@foo.com', | ||
'alice@bar.com', | ||
$user3->getEmail() | ||
); | ||
} | ||
|
@@ -236,6 +250,8 @@ public function testLoadFixturesAndPurge(): void | |
$users | ||
); | ||
|
||
$this->getTestContainer()->get('doctrine')->getManager()->clear(); | ||
|
||
// Reload fixtures | ||
$this->databaseTool->loadFixtures([ | ||
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData', | ||
|
@@ -303,6 +319,29 @@ public function testLoadFixturesFiles(): void | |
$this->assertInstanceOf(User::class, $user); | ||
} | ||
|
||
/** | ||
* Load fixture which has a dependency. | ||
*/ | ||
public function testLoadDependentFixtures(): void | ||
{ | ||
$fixtures = $this->databaseTool->loadFixtures([ | ||
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadDependentUserData', | ||
]); | ||
|
||
$this->assertInstanceOf( | ||
'Doctrine\Common\DataFixtures\Executor\ORMExecutor', | ||
$fixtures | ||
); | ||
|
||
$users = $this->userRepository->findAll(); | ||
|
||
// The two files with fixtures have been loaded, there are 4 users. | ||
$this->assertCount( | ||
4, | ||
$users | ||
); | ||
} | ||
|
||
protected static function getKernelClass(): string | ||
{ | ||
return AppConfigMysqlKernel::class; | ||
|
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 |
---|---|---|
|
@@ -165,7 +165,7 @@ public function loadAllFixtures(): void | |
$repository | ||
); | ||
|
||
$users = $this->userRepository->findAll(); | ||
$users = $repository->findAll(); | ||
|
||
// The fixture group myGroup contains 3 users | ||
$this->assertCount( | ||
|
@@ -188,7 +188,7 @@ public function loadAllFixtures(): void | |
$repository | ||
); | ||
|
||
$users = $this->userRepository->findAll(); | ||
$users = $repository->findAll(); | ||
|
||
// Loading all fixtures results in 12 users. | ||
$this->assertCount( | ||
|
@@ -209,28 +209,49 @@ public function testAppendFixtures(): void | |
); | ||
|
||
// Load data from database | ||
/** @var User $user */ | ||
$user = $this->userRepository | ||
$users = $this->userRepository->findAll(); | ||
|
||
// Check that there are 3 users. | ||
$this->assertCount( | ||
3, | ||
$users | ||
); | ||
|
||
// Load data from database | ||
/** @var User $user1 */ | ||
$user1 = $this->userRepository | ||
->findOneBy([ | ||
'id' => 1, | ||
]) | ||
; | ||
|
||
$this->assertSame( | ||
'[email protected]', | ||
$user->getEmail() | ||
$user1->getEmail() | ||
); | ||
|
||
/** @var User $user */ | ||
$user = $this->userRepository | ||
/** @var User $user2 */ | ||
$user2 = $this->userRepository | ||
->findOneBy([ | ||
'id' => 2, | ||
]) | ||
; | ||
|
||
$this->assertSame( | ||
'[email protected]', | ||
$user2->getEmail() | ||
); | ||
|
||
/** @var User $user3 */ | ||
$user3 = $this->userRepository | ||
->findOneBy([ | ||
'id' => 3, | ||
]) | ||
; | ||
|
||
$this->assertSame( | ||
'bar@foo.com', | ||
$user->getEmail() | ||
'alice@bar.com', | ||
$user3->getEmail() | ||
); | ||
} | ||
|
||
|
@@ -390,8 +411,12 @@ public function testLoadFixturesFilesPaths(): void | |
$fixtures | ||
); | ||
|
||
$fixtureId = 'user_id_1'; | ||
|
||
$this->assertArrayHasKey($fixtureId, $fixtures); | ||
|
||
/** @var User $user1 */ | ||
$user1 = $fixtures['id1']; | ||
$user1 = $fixtures[$fixtureId]; | ||
|
||
$this->assertIsString($user1->getEmail()); | ||
|
||
|
Oops, something went wrong.