Skip to content

Commit

Permalink
reset-password cleanup / improve phpstan compat out of the box
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed Apr 21, 2024
1 parent 3e1a093 commit 034963f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Maker/MakeResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bundle\MakerBundle\Maker;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use PhpParser\Builder\Param;
use Symfony\Bridge\Twig\AppVariable;
Expand Down Expand Up @@ -365,7 +364,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$useStatements = new UseStatementGenerator([
$userClassNameDetails->getFullName(),
$userRepositoryDetails->getFullName(),
EntityManager::class,
EntityManagerInterface::class,
KernelBrowser::class,
WebTestCase::class,
UserPasswordHasherInterface::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class ResetPasswordTest extends WebTestCase
{
private KernelBrowser $client;
private EntityManager $em;
private EntityManagerInterface $em;
private <?= $user_repo_short_name ?> $userRepository;

protected function setUp(): void
Expand All @@ -15,8 +15,12 @@ protected function setUp(): void

// Ensure we have a clean database
$container = static::getContainer();
$this->em = $container->get('doctrine')->getManager();
$this->userRepository = $this->em->getRepository(<?= $user_short_name ?>::class);

/** @var EntityManagerInterface $em */
$em = $container->get('doctrine')->getManager();
$this->em = $em;

$this->userRepository = $container->get(<?= $user_repo_short_name ?>::class);

foreach ($this->userRepository->findAll() as $user) {
$this->em->remove($user);
Expand All @@ -25,7 +29,7 @@ protected function setUp(): void
$this->em->flush();
}

public function testMaker(): void
public function testResetPasswordController(): void
{
// Create a test user
$user = (new <?= $user_short_name ?>())
Expand Down Expand Up @@ -85,6 +89,8 @@ public function testMaker(): void

$user = $this->userRepository->findOneBy(['email' => 'me@example.com']);

self::assertInstanceOf(<?= $user_short_name ?>::class, $user);

/** @var UserPasswordHasherInterface $passwordHasher */
$passwordHasher = static::getContainer()->get(UserPasswordHasherInterface::class);
self::assertTrue($passwordHasher->isPasswordValid($user, 'newStrongPassword'));
Expand Down

0 comments on commit 034963f

Please sign in to comment.