Skip to content

Commit 069bd64

Browse files
committed
moving XML projects and other projects into different dir/namespace
This avoids the metadata being cached in one test, then used in the next. These tests are a bit of a mess, this is more of a workaround.
1 parent 389e07a commit 069bd64

File tree

10 files changed

+29
-27
lines changed

10 files changed

+29
-27
lines changed

tests/Doctrine/EntityRegeneratorTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function testRegenerateEntities(string $expectedDirName, bool $overwrite)
3535
$kernel,
3636
'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity',
3737
$expectedDirName,
38-
$overwrite
38+
$overwrite,
39+
'current_project'
3940
);
4041
}
4142

@@ -58,16 +59,17 @@ public function testXmlRegeneration()
5859
$this->doTestRegeneration(
5960
__DIR__.'/fixtures/xml_source_project',
6061
$kernel,
61-
'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity',
62+
'Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity',
6263
'expected_xml',
63-
false
64+
false,
65+
'current_project_xml'
6466
);
6567
}
6668

67-
private function doTestRegeneration(string $sourceDir, Kernel $kernel, string $namespace, string $expectedDirName, bool $overwrite)
69+
private function doTestRegeneration(string $sourceDir, Kernel $kernel, string $namespace, string $expectedDirName, bool $overwrite, string $targetDirName)
6870
{
6971
$fs = new Filesystem();
70-
$tmpDir = __DIR__.'/../tmp/current_project';
72+
$tmpDir = __DIR__.'/../tmp/'.$targetDirName;
7173
$fs->remove($tmpDir);
7274

7375
// 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
7981
$autoloaderUtil = $this->createMock(AutoloaderUtil::class);
8082
$autoloaderUtil->expects($this->any())
8183
->method('getPathForFutureClass')
82-
->willReturnCallback(function($className) use ($tmpDir) {
83-
$shortClassName = str_replace('Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\\', '', $className);
84+
->willReturnCallback(function($className) use ($tmpDir, $targetDirName) {
85+
$shortClassName = str_replace('Symfony\Bundle\MakerBundle\Tests\tmp\\'.$targetDirName.'\src\\', '', $className);
8486

8587
// strip the App\, change \ to / and add .php
8688
return $tmpDir.'/src/'.str_replace('\\', '/', $shortClassName).'.php';
@@ -197,7 +199,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
197199
'is_bundle' => false,
198200
'type' => 'xml',
199201
'dir' => '%kernel.root_dir%/config/doctrine',
200-
'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity',
202+
'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity',
201203
'alias' => 'EntityRegeneratorApp',
202204
]
203205
]
@@ -207,7 +209,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
207209

208210
public function getRootDir()
209211
{
210-
return __DIR__.'/../tmp/current_project';
212+
return __DIR__.'/../tmp/current_project_xml';
211213
}
212214
}
213215

tests/Doctrine/fixtures/expected_xml/src/Entity/UserAvatar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;
44

55
class UserAvatar
66
{

tests/Doctrine/fixtures/expected_xml/src/Entity/UserXml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;
44

55
use Doctrine\Common\Collections\ArrayCollection;
66
use Doctrine\Common\Collections\Collection;

tests/Doctrine/fixtures/expected_xml/src/Entity/XOther.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;
44

55
class XOther
66
{

tests/Doctrine/fixtures/expected_xml/src/Repository/UserRepository.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<?php
22

3-
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository;
44

5-
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\User;
5+
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\UserXml;
66
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
77
use Symfony\Bridge\Doctrine\RegistryInterface;
88

99
/**
10-
* @method User|null find($id, $lockMode = null, $lockVersion = null)
11-
* @method User|null findOneBy(array $criteria, array $orderBy = null)
12-
* @method User[] findAll()
13-
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
10+
* @method UserXml|null find($id, $lockMode = null, $lockVersion = null)
11+
* @method UserXml|null findOneBy(array $criteria, array $orderBy = null)
12+
* @method UserXml[] findAll()
13+
* @method UserXml[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
1414
*/
1515
class UserRepository extends ServiceEntityRepository
1616
{
1717
public function __construct(RegistryInterface $registry)
1818
{
19-
parent::__construct($registry, User::class);
19+
parent::__construct($registry, UserXml::class);
2020
}
2121

2222
// /**
23-
// * @return User[] Returns an array of User objects
23+
// * @return UserXml[] Returns an array of UserXml objects
2424
// */
2525
/*
2626
public function findByExampleField($value)
@@ -37,7 +37,7 @@ public function findByExampleField($value)
3737
*/
3838

3939
/*
40-
public function findOneBySomeField($value): ?User
40+
public function findOneBySomeField($value): ?UserXml
4141
{
4242
return $this->createQueryBuilder('u')
4343
->andWhere('u.exampleField = :val')

tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository;
44

5-
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\XOther;
5+
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\XOther;
66
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
77
use Symfony\Bridge\Doctrine\RegistryInterface;
88

tests/Doctrine/fixtures/xml_source_project/config/doctrine/UserAvatar.orm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
44
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
55

6-
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\UserAvatar">
6+
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\UserAvatar">
77
<id name="id" type="integer">
88
<generator strategy="AUTO" />
99
</id>

tests/Doctrine/fixtures/xml_source_project/config/doctrine/UserXml.orm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
44
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
55

6-
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\UserXml" repository-class="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository\UserRepository">
6+
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\UserXml" repository-class="Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository\UserRepository">
77
<id name="id" type="integer">
88
<generator strategy="AUTO" />
99
</id>

tests/Doctrine/fixtures/xml_source_project/config/doctrine/XOther.orm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
44
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
55

6-
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\XOther" repository-class="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository\XOtherRepository">
6+
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\XOther" repository-class="Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository\XOtherRepository">
77
<id name="id" type="integer">
88
<generator strategy="AUTO" />
99
</id>

tests/Doctrine/fixtures/xml_source_project/src/Entity/UserXml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;
44

55
class UserXml
66
{

0 commit comments

Comments
 (0)