1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | /* |
||||
6 | Copyright (C) 2006-2014 David Négrier - THE CODING MACHINE |
||||
7 | |||||
8 | This program is free software; you can redistribute it and/or modify |
||||
9 | it under the terms of the GNU General Public License as published by |
||||
10 | the Free Software Foundation; either version 2 of the License, or |
||||
11 | (at your option) any later version. |
||||
12 | |||||
13 | This program is distributed in the hope that it will be useful, |
||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
16 | GNU General Public License for more details. |
||||
17 | |||||
18 | You should have received a copy of the GNU General Public License |
||||
19 | along with this program; if not, write to the Free Software |
||||
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
21 | */ |
||||
22 | |||||
23 | namespace TheCodingMachine\TDBM; |
||||
24 | |||||
25 | use Doctrine\Common\Cache\ArrayCache; |
||||
26 | use Mouf\Database\SchemaAnalyzer\SchemaAnalyzer; |
||||
27 | use TheCodingMachine\TDBM\Utils\ImmutableCaster; |
||||
28 | |||||
29 | class TDBMSchemaAnalyzerTest extends TDBMAbstractServiceTest |
||||
30 | { |
||||
31 | /** |
||||
32 | * @var TDBMSchemaAnalyzer |
||||
33 | */ |
||||
34 | protected $tdbmSchemaAnalyzer; |
||||
35 | |||||
36 | protected function setUp(): void |
||||
37 | { |
||||
38 | parent::setUp(); |
||||
39 | $schemaAnalyzer = new SchemaAnalyzer(self::getConnection()->createSchemaManager(), new ArrayCache(), 'prefix_'); |
||||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||||
40 | $schemaLockFileDumper = new SchemaLockFileDumper(self::getConnection(), new ArrayCache(), Configuration::getDefaultLockFilePath()); |
||||
0 ignored issues
–
show
The class
Doctrine\Common\Cache\ArrayCache has been deprecated: Deprecated without replacement in doctrine/cache 1.11. This class will be dropped in 2.0
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
41 | $this->tdbmSchemaAnalyzer = new TDBMSchemaAnalyzer(self::getConnection(), new ArrayCache(), $schemaAnalyzer, $schemaLockFileDumper); |
||||
0 ignored issues
–
show
The class
Doctrine\Common\Cache\ArrayCache has been deprecated: Deprecated without replacement in doctrine/cache 1.11. This class will be dropped in 2.0
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
42 | } |
||||
43 | |||||
44 | public function testGetIncomingForeignKeys(): void |
||||
45 | { |
||||
46 | $fks = $this->tdbmSchemaAnalyzer->getIncomingForeignKeys('users'); |
||||
47 | $this->assertCount(1, $fks); |
||||
48 | } |
||||
49 | |||||
50 | public function testGetIncomingForeignKeys2(): void |
||||
51 | { |
||||
52 | $fks = $this->tdbmSchemaAnalyzer->getIncomingForeignKeys('contact'); |
||||
53 | $this->assertCount(1, $fks); |
||||
54 | } |
||||
55 | |||||
56 | public function testGetIncomingForeignKeys3(): void |
||||
57 | { |
||||
58 | $fks = $this->tdbmSchemaAnalyzer->getIncomingForeignKeys('country'); |
||||
59 | $this->assertCount(5, $fks); |
||||
60 | $tables = [$fks[0]->getLocalTableName(), $fks[1]->getLocalTableName(), $fks[2]->getLocalTableName(), $fks[3]->getLocalTableName(), $fks[4]->getLocalTableName()]; |
||||
61 | $this->assertContains('users', $tables); |
||||
62 | $this->assertContains('all_nullable', $tables); |
||||
63 | $this->assertContains('boats', $tables); |
||||
64 | $this->assertContains('states', $tables); |
||||
65 | } |
||||
66 | |||||
67 | public function testGetPivotTableLinkedToTable(): void |
||||
68 | { |
||||
69 | $pivotTables = $this->tdbmSchemaAnalyzer->getPivotTableLinkedToTable('rights'); |
||||
70 | $this->assertCount(1, $pivotTables); |
||||
71 | $this->assertEquals('roles_rights', $pivotTables[0]); |
||||
72 | |||||
73 | $pivotTables = $this->tdbmSchemaAnalyzer->getPivotTableLinkedToTable('animal'); |
||||
74 | $this->assertCount(0, $pivotTables); |
||||
75 | |||||
76 | $pivotTables = $this->tdbmSchemaAnalyzer->getPivotTableLinkedToTable('animal'); |
||||
77 | $this->assertCount(0, $pivotTables); |
||||
78 | } |
||||
79 | } |
||||
80 |