From 1b5fc3efb19ab441daadd8d334c92bf606784355 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 799905a6..d2ed69cc 100644 --- a/tests/Test/ConfigSqliteTest.php +++ b/tests/Test/ConfigSqliteTest.php @@ -371,8 +371,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); @@ -385,7 +397,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());