Skip to content

Commit b2e5847

Browse files
committed
add more tests
1 parent 78eccd3 commit b2e5847

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

Diff for: src/Repository/UserRepository.php

-7
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string
3939
$this->getEntityManager()->flush();
4040
}
4141

42-
public function remove(User $entity, bool $flush = false): void {
43-
$this->getEntityManager()->remove($entity);
44-
45-
if ($flush) {
46-
$this->getEntityManager()->flush();
47-
}
48-
}
4942

5043
public function createEmpty(string $email, bool $flush): User {
5144
$entity = new User();

Diff for: tests/Functional/Command/CreateUserTest.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Jozef Môstka
5+
* Date: 11. 9. 2024
6+
* Time: 20:30
7+
*/
8+
9+
namespace BugCatcher\Tests\Functional\Command;
10+
11+
use BugCatcher\Tests\App\Factory\UserFactory;
12+
use BugCatcher\Tests\App\KernelTestCase;
13+
use Symfony\Bundle\FrameworkBundle\Console\Application;
14+
use Symfony\Component\Console\Tester\CommandTester;
15+
use Zenstruck\Foundry\Test\ResetDatabase;
16+
17+
class CreateUserTest extends KernelTestCase
18+
{
19+
use ResetDatabase;
20+
21+
public function testCreateUser()
22+
{
23+
24+
25+
$application = new Application(self::$kernel);
26+
27+
$command = $application->find('app:create-user');
28+
$commandTester = new CommandTester($command);
29+
$commandTester->execute(array('command' => $command->getName(), 'username' => 'admin', 'password' => 'admin'));
30+
31+
$count = UserFactory::count();
32+
$this->assertEquals(1, $count);
33+
$user = UserFactory::first();
34+
$this->assertEquals('admin', $user->getEmail());
35+
$this->assertTrue($user->isEnabled());
36+
$this->assertEquals(['ROLE_ADMIN', "ROLE_USER"], $user->getRoles());
37+
$this->assertNotEmpty($user->getPassword());
38+
39+
}
40+
41+
}

0 commit comments

Comments
 (0)