diff --git a/tests/Doctrine/EntityRegeneratorTest.php b/tests/Doctrine/EntityRegeneratorTest.php index 8b5e7f250..154614ea0 100644 --- a/tests/Doctrine/EntityRegeneratorTest.php +++ b/tests/Doctrine/EntityRegeneratorTest.php @@ -33,15 +33,16 @@ public function testRegenerateEntities(string $expectedDirName, bool $overwrite) $this->doTestRegeneration( __DIR__.'/fixtures/source_project', $kernel, - 'Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity', + 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity', $expectedDirName, - $overwrite + $overwrite, + 'current_project' ); } public function getRegenerateEntitiesTests() { - yield 'regnerate_no_overwrite' => [ + yield 'regenerate_no_overwrite' => [ 'expected_no_overwrite', false ]; @@ -58,16 +59,17 @@ public function testXmlRegeneration() $this->doTestRegeneration( __DIR__.'/fixtures/xml_source_project', $kernel, - 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity', + 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity', 'expected_xml', - false + false, + 'current_project_xml' ); } - private function doTestRegeneration(string $sourceDir, Kernel $kernel, string $namespace, string $expectedDirName, bool $overwrite) + private function doTestRegeneration(string $sourceDir, Kernel $kernel, string $namespace, string $expectedDirName, bool $overwrite, string $targetDirName) { $fs = new Filesystem(); - $tmpDir = __DIR__.'/../tmp/current_project'; + $tmpDir = __DIR__.'/../tmp/'.$targetDirName; $fs->remove($tmpDir); // if traits (Timestampable, Teamable) gets copied into new project, tests will fail because of double exclusion @@ -79,8 +81,8 @@ private function doTestRegeneration(string $sourceDir, Kernel $kernel, string $n $autoloaderUtil = $this->createMock(AutoloaderUtil::class); $autoloaderUtil->expects($this->any()) ->method('getPathForFutureClass') - ->willReturnCallback(function($className) use ($tmpDir) { - $shortClassName = str_replace('Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\\', '', $className); + ->willReturnCallback(function($className) use ($tmpDir, $targetDirName) { + $shortClassName = str_replace('Symfony\Bundle\MakerBundle\Tests\tmp\\'.$targetDirName.'\src\\', '', $className); // strip the App\, change \ to / and add .php return $tmpDir.'/src/'.str_replace('\\', '/', $shortClassName).'.php'; @@ -152,7 +154,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'is_bundle' => false, 'type' => 'annotation', 'dir' => '%kernel.root_dir%/src/Entity', - 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity', + 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity', 'alias' => 'EntityRegeneratorApp', ] ] @@ -197,7 +199,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'is_bundle' => false, 'type' => 'xml', 'dir' => '%kernel.root_dir%/config/doctrine', - 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity', + 'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity', 'alias' => 'EntityRegeneratorApp', ] ] @@ -207,13 +209,13 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load public function getRootDir() { - return __DIR__.'/../tmp/current_project'; + return __DIR__.'/../tmp/current_project_xml'; } } class AllButTraitsIterator extends \RecursiveFilterIterator { public function accept() { - return !in_array($this->current()->getFilename(), ['TeamTrait.php', 'TimestampableTrait.php']); + return !in_array($this->current()->getFilename(), []); } } diff --git a/tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/BaseClient.php b/tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/BaseClient.php index 640514442..d2286f766 100644 --- a/tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/BaseClient.php +++ b/tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/BaseClient.php @@ -1,6 +1,6 @@ id; } - public function getUser(): ?User + public function getUser(): ?UserXml { return $this->user; } - public function setUser(?User $user): self + public function setUser(?UserXml $user): self { $this->user = $user; diff --git a/tests/Doctrine/fixtures/expected_xml/src/Entity/User.php b/tests/Doctrine/fixtures/expected_xml/src/Entity/UserXml.php similarity index 93% rename from tests/Doctrine/fixtures/expected_xml/src/Entity/User.php rename to tests/Doctrine/fixtures/expected_xml/src/Entity/UserXml.php index e8cfaf008..b5df783be 100644 --- a/tests/Doctrine/fixtures/expected_xml/src/Entity/User.php +++ b/tests/Doctrine/fixtures/expected_xml/src/Entity/UserXml.php @@ -1,11 +1,11 @@ createQueryBuilder('u') ->andWhere('u.exampleField = :val') diff --git a/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php b/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php index fc4bc05b1..0db82d653 100644 --- a/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php +++ b/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Doctrine/fixtures/xml_source_project/config/doctrine/User.orm.xml b/tests/Doctrine/fixtures/xml_source_project/config/doctrine/UserXml.orm.xml similarity index 84% rename from tests/Doctrine/fixtures/xml_source_project/config/doctrine/User.orm.xml rename to tests/Doctrine/fixtures/xml_source_project/config/doctrine/UserXml.orm.xml index da4715f6a..ae9ef5bd8 100644 --- a/tests/Doctrine/fixtures/xml_source_project/config/doctrine/User.orm.xml +++ b/tests/Doctrine/fixtures/xml_source_project/config/doctrine/UserXml.orm.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + diff --git a/tests/Doctrine/fixtures/xml_source_project/config/doctrine/XOther.orm.xml b/tests/Doctrine/fixtures/xml_source_project/config/doctrine/XOther.orm.xml index ac6753aff..8ebbbba0b 100644 --- a/tests/Doctrine/fixtures/xml_source_project/config/doctrine/XOther.orm.xml +++ b/tests/Doctrine/fixtures/xml_source_project/config/doctrine/XOther.orm.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + diff --git a/tests/Doctrine/fixtures/xml_source_project/src/Entity/User.php b/tests/Doctrine/fixtures/xml_source_project/src/Entity/UserXml.php similarity index 57% rename from tests/Doctrine/fixtures/xml_source_project/src/Entity/User.php rename to tests/Doctrine/fixtures/xml_source_project/src/Entity/UserXml.php index cb8d12979..8aee6702f 100644 --- a/tests/Doctrine/fixtures/xml_source_project/src/Entity/User.php +++ b/tests/Doctrine/fixtures/xml_source_project/src/Entity/UserXml.php @@ -1,8 +1,8 @@