diff --git a/tests/App/Entity/User.php b/tests/App/Entity/User.php index d85cdbd9..944766a3 100644 --- a/tests/App/Entity/User.php +++ b/tests/App/Entity/User.php @@ -31,7 +31,6 @@ class User implements UserInterface * @var int * @ORM\Id() * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; diff --git a/tests/Test/WebTestCaseConfigTest.php b/tests/Test/WebTestCaseConfigTest.php index 7bff03c0..f13e4825 100644 --- a/tests/Test/WebTestCaseConfigTest.php +++ b/tests/Test/WebTestCaseConfigTest.php @@ -112,7 +112,6 @@ public function testIndexAuthenticatedClient(): void */ public function testIndexAuthenticationLoginAs(): void { - $this->schemaUpdate(); $user = $this->loadTestFixtures(); $loginAs = $this->loginAs($user, 'secured_area'); @@ -151,7 +150,6 @@ public function testIndexAuthenticationLoginAs(): void */ public function testIndexAuthenticationLoginClient(): void { - $this->schemaUpdate(); $user = $this->loadTestFixtures(); $this->client = static::makeClient(); @@ -189,7 +187,6 @@ public function testIndexAuthenticationLoginClient(): void */ public function testAllowedQueriesExceededException(): void { - $this->schemaUpdate(); $user = $this->loadTestFixtures(); $this->assertInstanceOf( diff --git a/tests/Traits/LiipAcmeFixturesTrait.php b/tests/Traits/LiipAcmeFixturesTrait.php index 01a0ecea..69c34fa7 100644 --- a/tests/Traits/LiipAcmeFixturesTrait.php +++ b/tests/Traits/LiipAcmeFixturesTrait.php @@ -19,28 +19,14 @@ trait LiipAcmeFixturesTrait { - public function schemaUpdate(): void - { - // Create database - $kernel = $this->getContainer()->get('kernel'); - - $application = new Application($kernel); - - $command = $application->find('doctrine:schema:update'); - $commandTester = new CommandTester($command); - $return = $commandTester->execute([ - '--force' => true, - ]); - - $this->assertSame(0, $return, $commandTester->getDisplay()); - } - public function loadTestFixtures(): User { + $this->resetSchema(); + $user1 = new User(); $user1->setId(1); $user1->setName('foo bar'); - $user1->setEmail('foo@bar.com'); + $user1->setEmail('foo@example'); $user1->setPassword('12341234'); $user1->setAlgorithm('plaintext'); $user1->setEnabled(true); @@ -52,10 +38,33 @@ public function loadTestFixtures(): User $user2 = clone $user1; $user2->setId(2); + $user2->setName('alice bob'); + $user2->setEmail('alice@example.com'); $manager->persist($user2); $manager->flush(); return $user1; } + + private function resetSchema(): void + { + // Create database + $kernel = $this->getContainer()->get('kernel'); + + $application = new Application($kernel); + + $command = $application->find('doctrine:schema:update'); + $commandTester = new CommandTester($command); + $return = $commandTester->execute([ + '--force' => true, + ]); + + $this->assertSame(0, $return, $commandTester->getDisplay()); + + $manager = $this->getContainer()->get('doctrine')->getManager(); + + $connection = $manager->getConnection(); + $connection->query('DELETE FROM liip_user'); + } }