@@ -34,7 +34,6 @@ protected function setUpDatabase(string $schemaFile = null): void
34
34
35
35
$ this ->getConnection ();
36
36
37
- $ this ->unsetStatsExpiry ();
38
37
$ this ->createTables ();
39
38
$ this ->truncateTables ();
40
39
@@ -53,6 +52,24 @@ protected function getConnection(): PDO
53
52
return $ this ->container ->get (PDO ::class);
54
53
}
55
54
55
+ /**
56
+ * Create tables.
57
+ *
58
+ * @return void
59
+ */
60
+ protected function createTables (): void
61
+ {
62
+ if (defined ('DB_TEST_TRAIT_INIT ' )) {
63
+ return ;
64
+ }
65
+
66
+ $ this ->unsetStatsExpiry ();
67
+ $ this ->dropTables ();
68
+ $ this ->importSchema ();
69
+
70
+ define ('DB_TEST_TRAIT_INIT ' , 1 );
71
+ }
72
+
56
73
/**
57
74
* Workaround for MySQL 8: update_time not working.
58
75
*
@@ -62,10 +79,10 @@ protected function getConnection(): PDO
62
79
*/
63
80
private function unsetStatsExpiry ()
64
81
{
65
- $ isMySql = strpos ($ this ->getDatabaseVariable ('version_comment ' ), 'MySQL ' ) !== false ;
82
+ $ isMariaDb = strpos ($ this ->getDatabaseVariable ('version_comment ' ), 'MariaDB ' ) !== false ;
66
83
$ version = $ this ->getDatabaseVariable ('version ' );
67
84
68
- if ($ isMySql && version_compare ($ version , '8.0.0 ' ) >= 0 ) {
85
+ if (! $ isMariaDb && version_compare ($ version , '8.0.0 ' , ' >= ' ) && version_compare ( $ version , ' 10.0.0 ' , ' < ' ) ) {
69
86
$ this ->getConnection ()->exec ('SET information_schema_stats_expiry=0; ' );
70
87
}
71
88
}
@@ -93,23 +110,6 @@ protected function getDatabaseVariable(string $variable): string
93
110
return (string )$ row ['Value ' ];
94
111
}
95
112
96
- /**
97
- * Create tables.
98
- *
99
- * @return void
100
- */
101
- protected function createTables (): void
102
- {
103
- if (defined ('DB_TEST_TRAIT_INIT ' )) {
104
- return ;
105
- }
106
-
107
- $ this ->dropTables ();
108
- $ this ->importSchema ();
109
-
110
- define ('DB_TEST_TRAIT_INIT ' , 1 );
111
- }
112
-
113
113
/**
114
114
* Clean up database. Truncate tables.
115
115
*
0 commit comments