Skip to content

Commit

Permalink
Fix test testLoadFixturesFilesWithPurgeModeTruncate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed May 30, 2021
1 parent 1304b07 commit 1b5fc3e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/Test/ConfigSqliteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 1b5fc3e

Please sign in to comment.