Skip to content

Commit

Permalink
Fix test testLoadFixturesFilesWithPurgeModeTruncate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Sep 15, 2021
1 parent 64b72f5 commit be20892
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 @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit be20892

Please sign in to comment.