-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7841 SchemaTool generates extra diff for platforms without FK support
- Loading branch information
Showing
3 changed files
with
101 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
tests/Doctrine/Tests/ORM/Functional/SchemaTool/SqliteSchemaToolTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\SchemaTool; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ORM\Annotation as ORM; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\ORM\Tools\SchemaTool; | ||
use Doctrine\Tests\OrmTestCase; | ||
use Doctrine\Tests\TestUtil; | ||
|
||
class SqliteSchemaToolTest extends OrmTestCase | ||
{ | ||
/** @var EntityManagerInterface */ | ||
private $em; | ||
/** @var SchemaTool */ | ||
private $schemaTool; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->em = $this->getTestEntityManager(TestUtil::getConnection()); | ||
|
||
$this->schemaTool = new SchemaTool($this->em); | ||
} | ||
|
||
public function testForeignKeysNotCompare() : void | ||
{ | ||
if ($this->em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { | ||
$this->markTestSkipped('Test for platforms without foreign keys support'); | ||
} | ||
$class = $this->em->getClassMetadata(SqliteSchemaToolChild::class); | ||
$this->schemaTool->updateSchema([$class], true); | ||
$diff = $this->schemaTool->getUpdateSchemaSql([$class]); | ||
|
||
self::assertEmpty($diff); | ||
|
||
$this->schemaTool->dropSchema([$class]); | ||
} | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class SqliteSchemaToolParent | ||
{ | ||
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */ | ||
public $id; | ||
|
||
/** @ORM\OneToMany(targetEntity=SqliteSchemaToolChild::class, mappedBy="parent") */ | ||
public $children; | ||
|
||
public function __construct() | ||
{ | ||
$this->children = new ArrayCollection(); | ||
} | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class SqliteSchemaToolChild | ||
{ | ||
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */ | ||
public $id; | ||
|
||
/** @ORM\ManyToOne(targetEntity=SqliteSchemaToolParent::class) */ | ||
public $parent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters