Skip to content

Commit aa37ea1

Browse files
committed
minor #332 Debugging test failures (weaverryan)
This PR was merged into the 1.0-dev branch. Discussion ---------- Debugging test failures Recently, during an unrelated change, the tests started failing with a "Cannot declare class" error that I can't repeat locally. Trying to debug it... Commits ------- 2dc123c updating namespace so the autoloader finds things in the correct, final location
2 parents bd8a467 + 2dc123c commit aa37ea1

33 files changed

+61
-59
lines changed

tests/Doctrine/EntityRegeneratorTest.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ public function testRegenerateEntities(string $expectedDirName, bool $overwrite)
3333
$this->doTestRegeneration(
3434
__DIR__.'/fixtures/source_project',
3535
$kernel,
36-
'Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity',
36+
'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity',
3737
$expectedDirName,
38-
$overwrite
38+
$overwrite,
39+
'current_project'
3940
);
4041
}
4142

4243
public function getRegenerateEntitiesTests()
4344
{
44-
yield 'regnerate_no_overwrite' => [
45+
yield 'regenerate_no_overwrite' => [
4546
'expected_no_overwrite',
4647
false
4748
];
@@ -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';
@@ -152,7 +154,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
152154
'is_bundle' => false,
153155
'type' => 'annotation',
154156
'dir' => '%kernel.root_dir%/src/Entity',
155-
'prefix' => 'Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity',
157+
'prefix' => 'Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity',
156158
'alias' => 'EntityRegeneratorApp',
157159
]
158160
]
@@ -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,13 +209,13 @@ 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

214216
class AllButTraitsIterator extends \RecursiveFilterIterator
215217
{
216218
public function accept() {
217-
return !in_array($this->current()->getFilename(), ['TeamTrait.php', 'TimestampableTrait.php']);
219+
return !in_array($this->current()->getFilename(), []);
218220
}
219221
}

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/BaseClient.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
66

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/Client.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

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

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/Embed.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
66

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/Tag.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
66

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/User.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

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

tests/Doctrine/fixtures/expected_no_overwrite/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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
66

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/UserProfile.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
66

tests/Doctrine/fixtures/expected_overwrite/src/Entity/BaseClient.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
66

tests/Doctrine/fixtures/expected_overwrite/src/Entity/Client.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\Doctrine\fixtures\source_project\src\Entity;
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
44

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

0 commit comments

Comments
 (0)