Skip to content

Commit 6e64745

Browse files
committed
Add a test to cover case with Translator installed
1 parent a00d568 commit 6e64745

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/Maker/MakeResetPasswordTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,49 @@ public function getTestDetails()
7676
}),
7777
];
7878

79+
yield 'it_generates_with_translator_installed' => [$this->createResetPasswordTest()
80+
->addExtraDependencies('symfony/translation')
81+
->run(function (MakerTestRunner $runner) {
82+
$this->makeUser($runner);
83+
84+
$output = $runner->runMaker([
85+
'App\Entity\User',
86+
'app_home',
87+
'victor@symfonycasts.com',
88+
'SymfonyCasts',
89+
]);
90+
91+
$this->assertStringContainsString('Success', $output);
92+
93+
$generatedFiles = [
94+
'src/Controller/ResetPasswordController.php',
95+
'src/Entity/ResetPasswordRequest.php',
96+
'src/Form/ChangePasswordFormType.php',
97+
'src/Form/ResetPasswordRequestFormType.php',
98+
'src/Repository/ResetPasswordRequestRepository.php',
99+
'templates/reset_password/check_email.html.twig',
100+
'templates/reset_password/email.html.twig',
101+
'templates/reset_password/request.html.twig',
102+
'templates/reset_password/reset.html.twig',
103+
];
104+
105+
foreach ($generatedFiles as $file) {
106+
$this->assertFileExists($runner->getPath($file));
107+
}
108+
109+
$configFileContents = file_get_contents($runner->getPath('config/packages/reset_password.yaml'));
110+
111+
// Flex recipe adds comments in reset_password.yaml, check file was replaced by maker
112+
$this->assertStringNotContainsString('#', $configFileContents);
113+
114+
$resetPasswordConfig = $runner->readYaml('config/packages/reset_password.yaml');
115+
116+
$this->assertSame('App\Repository\ResetPasswordRequestRepository', $resetPasswordConfig['symfonycasts_reset_password']['request_password_repository']);
117+
118+
$this->runResetPasswordTest($runner, 'it_generates_with_normal_setup.php');
119+
}),
120+
];
121+
79122
yield 'it_generates_with_custom_config' => [$this->createResetPasswordTest()
80123
->run(function (MakerTestRunner $runner) {
81124
$runner->deleteFile('config/packages/reset_password.yaml');

0 commit comments

Comments
 (0)