8000 reset-password cleanup / improve phpstan compat out of the box · symfony/maker-bundle@034963f · GitHub
[go: up one dir, main page]

Skip to content

Commit 034963f

Browse files
committed
reset-password cleanup / improve phpstan compat out of the box
1 parent 3e1a093 commit 034963f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Maker/MakeResetPassword.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Maker;
1313

14-
use Doctrine\ORM\EntityManager;
1514
use Doctrine\ORM\EntityManagerInterface;
1615
use PhpParser\Builder\Param;
1716
use Symfony\Bridge\Twig\AppVariable;
@@ -365,7 +364,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
365364
$useStatements = new UseStatementGenerator([
366365
$userClassNameDetails->getFullName(),
367366
$userRepositoryDetails->getFullName(),
368-
EntityManager::class,
367+
EntityManagerInterface::class,
369368
KernelBrowser::class,
370369
WebTestCase::class,
371370
UserPasswordHasherInterface::class,

src/Resources/skeleton/resetPassword/Test.ResetPasswordController.tpl.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class ResetPasswordTest extends WebTestCase
77
{
88
private KernelBrowser $client;
9-
private EntityManager $em;
9+
private EntityManagerInterface $em;
1010
private <?= $user_repo_short_name ?> $userRepository;
1111

1212
protected function setUp(): void
@@ -15,8 +15,12 @@ protected function setUp(): void
1515

1616
// Ensure we have a clean database
1717
$container = static::getContainer();
18-
$this->em = $container->get('doctrine')->getManager();
19-
$this->userRepository = $this->em->getRepository(<?= $user_short_name ?>::class);
18+
19+
/** @var EntityManagerInterface $em */
20+
$em = $container->get('doctrine')->getManager();
21+
$this->em = $em;
22+
23+
$this->userRepository = $container->get(<?= $user_repo_short_name ?>::class);
2024

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

28-
public function testMaker(): void
32+
public function testResetPasswordController(): void
2933
{
3034
// Create a test user
3135
$user = (new <?= $user_short_name ?>())
@@ -85,6 +89,8 @@ public function testMaker(): void
8589

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

92+
self::assertInstanceOf(<?= $user_short_name ?>::class, $user);
93+
8894
/** @var UserPasswordHasherInterface $passwordHasher */
8995
$passwordHasher = static::getContainer()->get(UserPasswordHasherInterface::class);
9096
self::assertTrue($passwordHasher->isPasswordValid($user, 'newStrongPassword'));

0 commit comments

Comments
 (0)
0