Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tito10047 committed Oct 8, 2024
1 parent 78eccd3 commit b2e5847
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
41 changes: 41 additions & 0 deletions tests/Functional/Command/CreateUserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Created by PhpStorm.
* User: Jozef Môstka
* Date: 11. 9. 2024
* Time: 20:30
*/

namespace BugCatcher\Tests\Functional\Command;

use BugCatcher\Tests\App\Factory\UserFactory;
use BugCatcher\Tests\App\KernelTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Zenstruck\Foundry\Test\ResetDatabase;

class CreateUserTest extends KernelTestCase
{
use ResetDatabase;

public function testCreateUser()
{


$application = new Application(self::$kernel);

$command = $application->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());

}

}

0 comments on commit b2e5847

Please sign in to comment.