From b2e5847eb6bcb4e19c6a677a43194b423c9b492f Mon Sep 17 00:00:00 2001 From: tito10047 Date: Tue, 8 Oct 2024 21:46:44 +0200 Subject: [PATCH] add more tests --- src/Repository/UserRepository.php | 7 ---- tests/Functional/Command/CreateUserTest.php | 41 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 tests/Functional/Command/CreateUserTest.php diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index ef09839..1ecd375 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -39,13 +39,6 @@ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $this->getEntityManager()->flush(); } - public function remove(User $entity, bool $flush = false): void { - $this->getEntityManager()->remove($entity); - - if ($flush) { - $this->getEntityManager()->flush(); - } - } public function createEmpty(string $email, bool $flush): User { $entity = new User(); diff --git a/tests/Functional/Command/CreateUserTest.php b/tests/Functional/Command/CreateUserTest.php new file mode 100644 index 0000000..900b7d9 --- /dev/null +++ b/tests/Functional/Command/CreateUserTest.php @@ -0,0 +1,41 @@ +find('app:create-user'); + $commandTester = new CommandTester($command); + $commandTester->execute(array('command' => $command->getName(), 'username' => 'admin', 'password' => 'admin')); + + $count = UserFactory::count(); + $this->assertEquals(1, $count); + $user = UserFactory::first(); + $this->assertEquals('admin', $user->getEmail()); + $this->assertTrue($user->isEnabled()); + $this->assertEquals(['ROLE_ADMIN', "ROLE_USER"], $user->getRoles()); + $this->assertNotEmpty($user->getPassword()); + + } + +} \ No newline at end of file