4
4
5
5
namespace Doctrine \DBAL \Tests \Functional \Schema ;
6
6
7
- use Doctrine \DBAL \Platforms \AbstractMySQLPlatform ;
8
- use Doctrine \DBAL \Platforms \AbstractPlatform ;
9
- use Doctrine \DBAL \Schema \AbstractSchemaManager ;
10
- use Doctrine \DBAL \Schema \Comparator ;
7
+ use Doctrine \DBAL \Schema \ColumnDiff ;
11
8
use Doctrine \DBAL \Schema \Table ;
12
9
use Doctrine \DBAL \Tests \Functional \Schema \Types \MoneyType ;
13
10
use Doctrine \DBAL \Tests \FunctionalTestCase ;
25
22
*/
26
23
class CustomIntrospectionTest extends FunctionalTestCase
27
24
{
28
- private AbstractSchemaManager $ schemaManager ;
29
-
30
- private Comparator $ comparator ;
31
-
32
- private AbstractPlatform $ platform ;
33
-
34
25
public static function setUpBeforeClass (): void
35
26
{
36
27
Type::addType ('money ' , MoneyType::class);
37
28
}
38
29
39
- protected function setUp (): void
40
- {
41
- $ this ->platform = $ this ->connection ->getDatabasePlatform ();
42
-
43
- if (! $ this ->platform instanceof AbstractMySQLPlatform) {
44
- self ::markTestSkipped ();
45
- }
46
-
47
- $ this ->schemaManager = $ this ->connection ->createSchemaManager ();
48
- $ this ->comparator = $ this ->schemaManager ->createComparator ();
49
- }
50
-
51
30
public function testCustomColumnIntrospection (): void
52
31
{
53
- $ tableName = 'test_custom_column_introspection ' ;
32
+ $ tableName = 'test_custom_column_intro ' ;
54
33
$ table = new Table ($ tableName );
55
34
56
35
$ table ->addColumn ('id ' , 'integer ' );
@@ -63,18 +42,21 @@ public function testCustomColumnIntrospection(): void
63
42
64
43
$ this ->dropAndCreateTable ($ table );
65
44
66
- $ onlineTable = $ this ->schemaManager ->introspectTable ($ tableName );
67
-
68
- $ diff = $ this ->comparator ->compareTables ($ table , $ onlineTable );
69
- $ changedCols = [];
45
+ $ schemaManager = $ this ->connection ->createSchemaManager ();
46
+ $ onlineTable = $ schemaManager ->introspectTable ($ tableName );
47
+ $ diff = $ schemaManager ->createComparator ()->compareTables ($ table , $ onlineTable );
48
+ $ changedCols = array_map (
49
+ static function (ColumnDiff $ columnDiff ): ?string {
50
+ $ column = $ columnDiff ->getOldColumn ();
70
51
71
- if (! $ diff ->isEmpty ()) {
72
- $ changedCols = array_map (static fn ($ c ) => $ c ->getOldColumnName ()->getName (), $ diff ->getModifiedColumns ());
73
- }
52
+ return $ column !== null ? $ column ->getName () : null ;
53
+ },
54
+ $ diff ->getModifiedColumns (),
55
+ );
74
56
75
57
self ::assertTrue ($ diff ->isEmpty (), sprintf (
76
58
'Tables should be identical. Differences detected in %s. ' ,
77
- implode (': ' , $ changedCols ),
59
+ implode (', ' , $ changedCols ),
78
60
));
79
61
}
80
62
}
0 commit comments