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