|
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
|
|
|
$this->schemaTool = new SchemaTool($this->em); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testForeignKeysNotCompare(): void |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
if ($this->em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { |
|
31
|
|
|
$this->markTestSkipped('Test for platforms without foreign keys support'); |
|
32
|
|
|
} |
|
33
|
|
|
$class = $this->em->getClassMetadata(SqliteSchemaToolChild::class); |
|
34
|
|
|
$this->schemaTool->updateSchema([$class], true); |
|
35
|
|
|
$diff = $this->schemaTool->getUpdateSchemaSql([$class]); |
|
36
|
|
|
|
|
37
|
|
|
self::assertEmpty($diff); |
|
38
|
|
|
|
|
39
|
|
|
$this->schemaTool->dropSchema([$class]); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @ORM\Entity |
|
45
|
|
|
*/ |
|
46
|
|
|
class SqliteSchemaToolParent |
|
47
|
|
|
{ |
|
48
|
|
|
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */ |
|
49
|
|
|
public $id; |
|
50
|
|
|
|
|
51
|
|
|
/** @ORM\OneToMany(targetEntity=SqliteSchemaToolChild::class, mappedBy="parent") */ |
|
52
|
|
|
public $children; |
|
53
|
|
|
|
|
54
|
|
|
public function __construct() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->children = new ArrayCollection(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @ORM\Entity |
|
62
|
|
|
*/ |
|
63
|
|
|
class SqliteSchemaToolChild |
|
64
|
|
|
{ |
|
65
|
|
|
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */ |
|
66
|
|
|
public $id; |
|
67
|
|
|
|
|
68
|
|
|
/** @ORM\ManyToOne(targetEntity=SqliteSchemaToolParent::class) */ |
|
69
|
|
|
public $parent; |
|
70
|
|
|
} |
|
71
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.