From 2168eb2a1e497768505d1eca5860b344c3ca38f2 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 15 Nov 2018 21:32:39 +0100 Subject: [PATCH] Implemented some basic tests for user repository --- .../Unit/Repository/UserRepositoryTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 application/tests/Unit/Repository/UserRepositoryTest.php diff --git a/application/tests/Unit/Repository/UserRepositoryTest.php b/application/tests/Unit/Repository/UserRepositoryTest.php new file mode 100644 index 0000000..b34f751 --- /dev/null +++ b/application/tests/Unit/Repository/UserRepositoryTest.php @@ -0,0 +1,55 @@ +entityManager = $kernel->getContainer()->get('doctrine')->getManager(); + $this->userRepository = $this->entityManager->getRepository(User::class); + } + + public function testCreation(): void + { + $user = new User(); + $user->setId(self::USER_ID); + $this->entityManager->persist($user); + $this->entityManager->flush(); + /** + * @var UserInterface + */ + $loadedUser = $this->userRepository->find(self::USER_ID); + $this->assertEquals(self::USER_ID, $loadedUser->getId()); + } + + /** + * {@inheritdoc} + * + * @see \Symfony\Bundle\FrameworkBundle\Test\KernelTestCase::tearDown() + */ + protected function tearDown(): void + { + parent::tearDown(); + $this->entityManager->close(); + $this->entityManager = null; + } +}