From be2089258b0f53d95f2784bac2229539bc8162b3 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Thu, 30 May 2019 22:50:07 +0200 Subject: [PATCH] Fix test testLoadFixturesFilesWithPurgeModeTruncate --- tests/Test/ConfigSqliteTest.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/Test/ConfigSqliteTest.php b/tests/Test/ConfigSqliteTest.php index 55795d66..01a5df6b 100644 --- a/tests/Test/ConfigSqliteTest.php +++ b/tests/Test/ConfigSqliteTest.php @@ -370,8 +370,20 @@ public function testLoadNonexistentFixturesFiles(): void */ public function testLoadFixturesFilesWithPurgeModeTruncate(): void { + // Load initial fixtures + $this->testLoadFixturesFiles(); + + $users = $this->userRepository->findAll(); + + // There are 10 users in the database + $this->assertSame( + 10, + \count($users) + ); + $this->databaseTool->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE); + // Load fixtures with append = true $fixtures = $this->databaseTool->loadAliceFixture([ '@AcmeBundle/DataFixtures/ORM/user.yml', ], true); @@ -384,7 +396,16 @@ public function testLoadFixturesFilesWithPurgeModeTruncate(): void $fixtures ); - $id = 1; + $users = $this->userRepository->findAll(); + + // There are only 10 users in the database + $this->assertSame( + 10, + \count($users) + ); + + // Auto-increment hasn't been altered, so ids start from 11 + $id = 11; /** @var User $user */ foreach ($fixtures as $user) { $this->assertSame($id++, $user->getId());