forked from symfony/maker-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature symfony#1488 allow the option to use ulid's for entity id's
- Loading branch information
Showing
12 changed files
with
271 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony MakerBundle package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\MakerBundle\Maker\Common; | ||
|
||
/** | ||
* @author Jesse Rushlow <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
enum EntityIdTypeEnum | ||
{ | ||
case INT; | ||
case UUID; | ||
case ULID; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Instead of using the default "int" type for the entity's "id", you can use the | ||
UUID type from Symfony's Uid component. | ||
<href=https://symfony.com/doc/current/components/uid.html#storing-uuids-in-databases>https://symfony.com/doc/current/components/uid.html#storing-uuids-in-databases</> | ||
|
||
<info>php %command.full_name% --with-uuid</info> | ||
|
||
Or you can use the ULID type from Symfony's Uid component. | ||
<href=https://symfony.com/doc/current/components/uid.html#storing-ulids-in-databases>https://symfony.com/doc/current/components/uid.html#storing-ulids-in-databases</> | ||
|
||
<info>php %command.full_name% --with-ulid</info> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,66 @@ public function getTestDetails(): \Generator | |
}), | ||
]; | ||
|
||
yield 'it_generates_with_ulid' => [$this->createMakerTest() | ||
->setSkippedPhpVersions(80100, 80109) | ||
->addExtraDependencies('symfony/uid') | ||
->run(function (MakerTestRunner $runner) { | ||
$this->makeUser($runner); | ||
|
||
$output = $runner->runMaker([ | ||
'App\Entity\User', | ||
'app_home', | ||
'[email protected]', | ||
'SymfonyCasts', | ||
], '--with-ulid'); | ||
|
||
$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)); | ||
} | ||
|
||
$resetPasswordRequestEntityContents = file_get_contents($runner->getPath('src/Entity/ResetPasswordRequest.php')); | ||
$this->assertStringContainsString('use Symfony\Component\Uid\Ulid;', $resetPasswordRequestEntityContents); | ||
$this->assertStringContainsString('[ORM\CustomIdGenerator(class: \'doctrine.ulid_generator\')]', $resetPasswordRequestEntityContents); | ||
|
||
$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']); | ||
|
||
$runner->writeFile( | ||
'config/packages/mailer.yaml', | ||
Yaml::dump(['framework' => [ | ||
'mailer' => ['dsn' => 'null://null'], | ||
]]) | ||
); | ||
|
||
$runner->copy( | ||
'make-reset-password/tests/it_generates_with_normal_setup.php', | ||
'tests/ResetPasswordFunctionalTest.php' | ||
); | ||
|
||
$runner->runTests(); | ||
}), | ||
]; | ||
|
||
yield 'it_generates_with_translator_installed' => [$this->createMakerTest() | ||
// @legacy - drop skipped versions when PHP 8.1 is no longer supported. | ||
->setSkippedPhpVersions(80100, 80109) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.