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 ;
11
- use Doctrine \DBAL \Schema \Table ;
7
+ use Doctrine \DBAL \Schema \ColumnDiff ;
8
+ use Doctrine \DBAL \Schema \Schema ;
12
9
use Doctrine \DBAL \Tests \Functional \Schema \Types \MoneyType ;
13
10
use Doctrine \DBAL \Tests \FunctionalTestCase ;
14
11
use Doctrine \DBAL \Types \Type ;
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 ' ;
54
- $ table = new Table ($ tableName );
32
+ $ tableName = 'test_custom_column_intro ' ;
33
+ $ schemaManager = $ this ->connection ->createSchemaManager ();
34
+ $ schema = new Schema ([], [], $ schemaManager ->createSchemaConfig ());
35
+ $ table = $ schema ->createTable ($ tableName );
55
36
56
37
$ table ->addColumn ('id ' , 'integer ' );
57
38
$ table ->addColumn ('quantity ' , 'decimal ' );
@@ -63,18 +44,20 @@ public function testCustomColumnIntrospection(): void
63
44
64
45
$ this ->dropAndCreateTable ($ table );
65
46
66
- $ onlineTable = $ this ->schemaManager ->introspectTable ($ tableName );
67
-
68
- $ diff = $ this ->comparator ->compareTables ($ table , $ onlineTable );
69
- $ changedCols = [];
47
+ $ onlineTable = $ schemaManager ->introspectTable ($ tableName );
48
+ $ diff = $ schemaManager ->createComparator ()->compareTables ($ onlineTable , $ table );
49
+ $ changedCols = array_map (
50
+ static function (ColumnDiff $ columnDiff ): ?string {
51
+ $ column = $ columnDiff ->getOldColumn ();
70
52
71
- if (! $ diff ->isEmpty ()) {
72
- $ changedCols = array_map (static fn ($ c ) => $ c ->getOldColumnName ()->getName (), $ diff ->getModifiedColumns ());
73
- }
53
+ return $ column !== null ? $ column ->getName () : null ;
54
+ },
55
+ $ diff ->getModifiedColumns (),
56
+ );
74
57
75
58
self ::assertTrue ($ diff ->isEmpty (), sprintf (
76
59
'Tables should be identical. Differences detected in %s. ' ,
77
- implode (': ' , $ changedCols ),
60
+ implode (', ' , $ changedCols ),
78
61
));
79
62
}
80
63
}
0 commit comments