1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\SchemaTool; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Doctrine\ORM\Annotation as ORM; |
9
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
10
|
|
|
use Doctrine\ORM\Tools\SchemaTool; |
11
|
|
|
use Doctrine\Tests\OrmTestCase; |
12
|
|
|
use Doctrine\Tests\TestUtil; |
13
|
|
|
|
14
|
|
|
class SqliteSchemaToolTest extends OrmTestCase |
15
|
|
|
{ |
16
|
|
|
/** @var EntityManagerInterface */ |
17
|
|
|
private $em; |
18
|
|
|
/** @var SchemaTool */ |
19
|
|
|
private $schemaTool; |
20
|
|
|
|
21
|
|
|
protected function setUp() |
22
|
|
|
{ |
23
|
|
|
parent::setUp(); |
24
|
|
|
$this->em = $this->getTestEntityManager(TestUtil::getConnection()); |
25
|
|
|
|
26
|
|
|
$this->schemaTool = new SchemaTool($this->em); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testForeignKeysNotCompare() : void |
30
|
|
|
{ |
31
|
|
|
if ($this->em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { |
32
|
|
|
$this->markTestSkipped('Test for platforms without foreign keys support'); |
33
|
|
|
} |
34
|
|
|
$class = $this->em->getClassMetadata(SqliteSchemaToolChild::class); |
35
|
|
|
$this->schemaTool->updateSchema([$class], true); |
36
|
|
|
$diff = $this->schemaTool->getUpdateSchemaSql([$class]); |
37
|
|
|
|
38
|
|
|
self::assertEmpty($diff); |
39
|
|
|
|
40
|
|
|
$this->schemaTool->dropSchema([$class]); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @ORM\Entity |
46
|
|
|
*/ |
47
|
|
|
class SqliteSchemaToolParent |
48
|
|
|
{ |
49
|
|
|
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */ |
50
|
|
|
public $id; |
51
|
|
|
|
52
|
|
|
/** @ORM\OneToMany(targetEntity=SqliteSchemaToolChild::class, mappedBy="parent") */ |
53
|
|
|
public $children; |
54
|
|
|
|
55
|
|
|
public function __construct() |
56
|
|
|
{ |
57
|
|
|
$this->children = new ArrayCollection(); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @ORM\Entity |
63
|
|
|
*/ |
64
|
|
|
class SqliteSchemaToolChild |
65
|
|
|
{ |
66
|
|
|
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */ |
67
|
|
|
public $id; |
68
|
|
|
|
69
|
|
|
/** @ORM\ManyToOne(targetEntity=SqliteSchemaToolParent::class) */ |
70
|
|
|
public $parent; |
71
|
|
|
} |
72
|
|
|
|