diff --git a/src/Maker/MakeEntity.php b/src/Maker/MakeEntity.php index 1774ffc35..0b58038f2 100644 --- a/src/Maker/MakeEntity.php +++ b/src/Maker/MakeEntity.php @@ -123,8 +123,6 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma return; } - $this->checkIsUsingUid($input); - $argument = $command->getDefinition()->getArgument('name'); $question = $this->createEntityClassQuestion($argument->getDescription()); $entityClassName ??= $io->askQuestion($question); @@ -171,6 +169,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void { + $this->checkIsUsingUid($input); $overwrite = $input->getOption('overwrite'); // the regenerate option has entirely custom behavior diff --git a/tests/Maker/MakeEntityTest.php b/tests/Maker/MakeEntityTest.php index c8826274f..2c10b2f4e 100644 --- a/tests/Maker/MakeEntityTest.php +++ b/tests/Maker/MakeEntityTest.php @@ -161,6 +161,24 @@ public function getTestDetails(): \Generator }), ]; + yield 'it_creates_a_new_class_with_uuid_and_class_name' => [$this->createMakeEntityTest() + ->addExtraDependencies('symfony/uid') + ->run(function (MakerTestRunner $runner) { + $runner->runMaker([ + // add not additional fields + '', + ], 'User --with-uuid'); + + $this->assertFileExists($runner->getPath('src/Entity/User.php')); + + $content = file_get_contents($runner->getPath('src/Entity/User.php')); + $this->assertStringContainsString('use Symfony\Component\Uid\Uuid;', $content); + $this->assertStringContainsString('[ORM\CustomIdGenerator(class: \'doctrine.uuid_generator\')]', $content); + + $this->runEntityTest($runner); + }), + ]; + yield 'it_creates_a_new_class_with_ulid' => [$this->createMakeEntityTest() ->addExtraDependencies('symfony/uid') ->run(function (MakerTestRunner $runner) {