Skip to content

Commit

Permalink
Add a test to cover case with Translator installed
Browse files Browse the repository at this point in the history
  • Loading branch information
bocharsky-bw committed Feb 16, 2022
1 parent a00d568 commit 6e64745
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/Maker/MakeResetPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,49 @@ public function getTestDetails()
}),
];

yield 'it_generates_with_translator_installed' => [$this->createResetPasswordTest()
->addExtraDependencies('symfony/translation')
->run(function (MakerTestRunner $runner) {
$this->makeUser($runner);

$output = $runner->runMaker([
'App\Entity\User',
'app_home',
'victor@symfonycasts.com',
'SymfonyCasts',
]);

$this->assertStringContainsString('Success', $output);

$generatedFiles = [
'src/Controller/ResetPasswordController.php',
'src/Entity/ResetPasswordRequest.php',
'src/Form/ChangePasswordFormType.php',
'src/Form/ResetPasswordRequestFormType.php',
'src/Repository/ResetPasswordRequestRepository.php',
'templates/reset_password/check_email.html.twig',
'templates/reset_password/email.html.twig',
'templates/reset_password/request.html.twig',
'templates/reset_password/reset.html.twig',
];

foreach ($generatedFiles as $file) {
$this->assertFileExists($runner->getPath($file));
}

$configFileContents = file_get_contents($runner->getPath('config/packages/reset_password.yaml'));

// Flex recipe adds comments in reset_password.yaml, check file was replaced by maker
$this->assertStringNotContainsString('#', $configFileContents);

$resetPasswordConfig = $runner->readYaml('config/packages/reset_password.yaml');

$this->assertSame('App\Repository\ResetPasswordRequestRepository', $resetPasswordConfig['symfonycasts_reset_password']['request_password_repository']);

$this->runResetPasswordTest($runner, 'it_generates_with_normal_setup.php');
}),
];

yield 'it_generates_with_custom_config' => [$this->createResetPasswordTest()
->run(function (MakerTestRunner $runner) {
$runner->deleteFile('config/packages/reset_password.yaml');
Expand Down

0 comments on commit 6e64745

Please sign in to comment.