File tree Expand file tree Collapse file tree
src/Services/DatabaseTools Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727use Liip \TestFixturesBundle \Event \PreFixtureBackupRestoreEvent ;
2828use Liip \TestFixturesBundle \Event \ReferenceSaveEvent ;
2929use Liip \TestFixturesBundle \LiipTestFixturesEvents ;
30+ use Symfony \Contracts \Service \ResetInterface ;
3031
3132/**
3233 * @author Aleksey Tupichenkov <alekseytupichenkov@gmail.com>
3334 */
34- class ORMDatabaseTool extends AbstractDbalDatabaseTool
35+ class ORMDatabaseTool extends AbstractDbalDatabaseTool implements ResetInterface
3536{
3637 /**
3738 * @var EntityManager
3839 */
3940 protected $ om ;
4041
42+ private ?ProxyReferenceRepository $ referenceRepository = null ;
43+
4144 /**
4245 * @var bool
4346 */
4447 private $ shouldEnableForeignKeyChecks = false ;
4548
49+ public function reset ()
50+ {
51+ $ this ->referenceRepository = null ;
52+ }
53+
4654 public function getType (): string
4755 {
4856 return 'ORM ' ;
4957 }
5058
5159 public function loadFixtures (array $ classNames = [], bool $ append = false ): AbstractExecutor
5260 {
53- $ referenceRepository = new ProxyReferenceRepository ($ this ->om );
61+ if (null === $ this ->referenceRepository || false === $ append ) {
62+ $ this ->referenceRepository = new ProxyReferenceRepository ($ this ->om );
63+ }
64+
65+ $ referenceRepository = $ this ->referenceRepository ;
5466
5567 /** @var Configuration $config */
5668 $ config = $ this ->om ->getConfiguration ();
Original file line number Diff line number Diff line change 22
33doctrine :
44 dbal :
5- url : ' sqlite:///%kernel.project_dir%/var/app .db'
5+ url : ' sqlite:///%kernel.cache_dir%/test .db'
66
Original file line number Diff line number Diff line change @@ -118,7 +118,6 @@ public function testLoadFixturesAndCheckBackup(): void
118118 */
119119 public function testLoadFixturesCheckReferences (): void
120120 {
121- $ this ->markTestSkipped ('This test is broken right now. ' );
122121 $ referenceRepository = $ this ->databaseTool ->loadFixtures ([
123122 'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData ' ,
124123 ])->getReferenceRepository ();
Original file line number Diff line number Diff line change @@ -140,10 +140,12 @@ public function testAppendFixtures(): void
140140 'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData ' ,
141141 ]);
142142
143- $ this ->databaseTool ->loadFixtures (
143+ $ referenceRepository = $ this ->databaseTool ->loadFixtures (
144144 ['Liip\Acme\Tests\App\DataFixtures\ORM\LoadSecondUserData ' ],
145145 true
146- );
146+ )->getReferenceRepository ();
147+
148+ $ this ->assertCount (2 , $ referenceRepository ->getReferences ());
147149
148150 // Load data from database
149151 $ users = $ this ->userRepository ->findAll ();
You can’t perform that action at this time.
0 commit comments