Skip to content

Debugging test failures #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions tests/Doctrine/EntityRegeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand All @@ -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
Expand All @@ -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';
Expand Down Expand Up @@ -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',
]
]
Expand Down Expand Up @@ -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',
]
]
Expand All @@ -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(), []);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;

class UserAvatar
{
Expand All @@ -13,12 +13,12 @@ public function getId(): ?int
return $this->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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;

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

class User
class UserXml
{
private $id;

Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/fixtures/expected_xml/src/Entity/XOther.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity;

class XOther
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository;

use Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\User;
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\UserXml;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;

/**
* @method User|null find($id, $lockMode = null, $lockVersion = null)
* @method User|null findOneBy(array $criteria, array $orderBy = null)
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method UserXml|null find($id, $lockMode = null, $lockVersion = null)
* @method UserXml|null findOneBy(array $criteria, array $orderBy = null)
* @method UserXml[] findAll()
* @method UserXml[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, User::class);
parent::__construct($registry, UserXml::class);
}

// /**
// * @return User[] Returns an array of User objects
// * @return UserXml[] Returns an array of UserXml objects
// */
/*
public function findByExampleField($value)
Expand All @@ -37,7 +37,7 @@ public function findByExampleField($value)
*/

/*
public function findOneBySomeField($value): ?User
public function findOneBySomeField($value): ?UserXml
{
return $this->createQueryBuilder('u')
->andWhere('u.exampleField = :val')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository;

use Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\XOther;
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\XOther;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/fixtures/source_project/src/Entity/Tag.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/fixtures/source_project/src/Entity/User.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Bundle\MakerBundle\Tests\Doctrine\fixtures\source_project\src\Entity;
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;

use Doctrine\ORM\Mapping as ORM;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\UserAvatar">
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\UserAvatar">
<id name="id" type="integer">
<generator strategy="AUTO" />
</id>
<many-to-one field="user" target-entity="User" inversed-by="avatars">
<many-to-one field="user" target-entity="UserXml" inversed-by="avatars">
<cascade>
<cascade-persist/>
<cascade-remove/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\User" repository-class="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository\UserRepository">
<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">
<id name="id" type="integer">
<generator strategy="AUTO" />
</id>
Expand Down
Loading