Skip to content

Commit

Permalink
bug #1381 fixing the generator of test when using make:crud (HiroKX)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.x-dev branch.

Discussion
----------

fixing the generator of test when using make:crud

Closes Issue #1377

Fixing the generation of test when using make:crud.

Commits
-------

50cfb71 fixing the generator of test when using make:crud
  • Loading branch information
weaverryan committed Oct 31, 2023
2 parents ab4b742 + 50cfb71 commit a4bfda9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 131 deletions.
10 changes: 4 additions & 6 deletions src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,17 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$repositoryClassName,
]);

$usesEntityManager = EntityManagerInterface::class === $repositoryClassName;

if ($usesEntityManager) {
$useStatements->addUseStatement(EntityRepository::class);
}
$useStatements->addUseStatement(EntityRepository::class);


if (EntityManagerInterface::class !== $repositoryClassName) {
$useStatements->addUseStatement(EntityManagerInterface::class);
}

$generator->generateFile(
'tests/Controller/'.$testClassDetails->getShortName().'.php',
$usesEntityManager ? 'crud/test/Test.EntityManager.tpl.php' : 'crud/test/Test.tpl.php',
'crud/test/Test.EntityManager.tpl.php',
[
'use_statements' => $useStatements,
'entity_full_class_name' => $entityClassDetails->getFullName(),
Expand All @@ -274,7 +272,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
'class_name' => Str::getShortClassName($testClassDetails->getFullName()),
'namespace' => Str::getNamespace($testClassDetails->getFullName()),
'form_fields' => $entityDoctrineDetails->getFormFields(),
'repository_class_name' => $usesEntityManager ? EntityManagerInterface::class : $repositoryVars['repository_class_name'],
'repository_class_name' => EntityManagerInterface::class,
'form_field_prefix' => strtolower(Str::asSnakeCase($entityTwigVarSingular)),
]
);
Expand Down
125 changes: 0 additions & 125 deletions src/Resources/skeleton/crud/test/Test.tpl.php

This file was deleted.

0 comments on commit a4bfda9

Please sign in to comment.