@@ -37,8 +37,7 @@ class_alias('\Doctrine\Persistence\ObjectManager', '\Doctrine\Common\Persistence
37
37
* they are disabled by default (see phpunit.xml.dist).
38
38
*
39
39
* In order to run them, you have to set the MySQL connection
40
- * parameters in the Tests/AppConfigMysql/config.yml file and
41
- * add “--exclude-group ""” when running PHPUnit.
40
+ * parameters in the Tests/AppConfigMysql/config.yml file.
42
41
*
43
42
* Use Tests/AppConfigMysql/AppConfigMysqlKernel.php instead of
44
43
* Tests/App/AppKernel.php.
@@ -95,7 +94,7 @@ public function testLoadEmptyFixtures(): void
95
94
/**
96
95
* @group mysql
97
96
*/
98
- public function testLoadFixtures (int $ firstUserId = 1 ): void
97
+ public function testLoadFixtures (): void
99
98
{
100
99
$ fixtures = $ this ->databaseTool ->loadFixtures ([
101
100
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData ' ,
@@ -135,7 +134,7 @@ public function testLoadFixtures(int $firstUserId = 1): void
135
134
/**
136
135
* @group mysql
137
136
*/
138
- public function testAppendFixtures (int $ firstUserId = 1 , int $ thirdUserId = 3 ): void
137
+ public function testAppendFixtures (): void
139
138
{
140
139
$ this ->databaseTool ->loadFixtures ([
141
140
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData ' ,
@@ -169,17 +168,31 @@ public function testAppendFixtures(int $firstUserId = 1, int $thirdUserId = 3):
169
168
$ user1 ->getEmail ()
170
169
);
171
170
172
- /** @var User $user */
171
+ /** @var User $user2 */
172
+ $ user2 = $ this ->userRepository
173
+ ->findOneBy ([
174
+
175
+ ])
176
+ ;
177
+
178
+ $ this ->assertNotNull ($ user2 );
179
+
180
+ $ this ->assertSame (
181
+
182
+ $ user2 ->getEmail ()
183
+ );
184
+
185
+ /** @var User $user3 */
173
186
$ user3 = $ this ->userRepository
174
187
->findOneBy ([
175
- 'email ' => 'bar@foo .com ' ,
188
+ 'email ' => 'alice@bar .com ' ,
176
189
])
177
190
;
178
191
179
192
$ this ->assertNotNull ($ user3 );
180
193
181
194
$ this ->assertSame (
182
- 'bar@foo .com ' ,
195
+ 'alice@bar .com ' ,
183
196
$ user3 ->getEmail ()
184
197
);
185
198
}
@@ -262,6 +275,8 @@ public function testLoadFixturesAndPurge(): void
262
275
$ users
263
276
);
264
277
278
+ $ this ->getTestContainer ()->get ('doctrine ' )->getManager ()->clear ();
279
+
265
280
// Reload fixtures
266
281
$ this ->databaseTool ->loadFixtures ([
267
282
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData ' ,
@@ -331,6 +346,29 @@ public function testLoadFixturesFiles(): void
331
346
$ this ->assertInstanceOf (User::class, $ user );
332
347
}
333
348
349
+ /**
350
+ * Load fixture which has a dependency.
351
+ */
352
+ public function testLoadDependentFixtures (): void
353
+ {
354
+ $ fixtures = $ this ->databaseTool ->loadFixtures ([
355
+ 'Liip\Acme\Tests\App\DataFixtures\ORM\LoadDependentUserData ' ,
356
+ ]);
357
+
358
+ $ this ->assertInstanceOf (
359
+ 'Doctrine\Common\DataFixtures\Executor\ORMExecutor ' ,
360
+ $ fixtures
361
+ );
362
+
363
+ $ users = $ this ->userRepository ->findAll ();
364
+
365
+ // The two files with fixtures have been loaded, there are 4 users.
366
+ $ this ->assertCount (
367
+ 4 ,
368
+ $ users
369
+ );
370
+ }
371
+
334
372
protected static function getKernelClass (): string
335
373
{
336
374
return AppConfigMysqlKernel::class;
0 commit comments