@@ -42,9 +42,9 @@ protected function tearDown(): void
42
42
unset($ this ->adapter );
43
43
}
44
44
45
- private function usingMysql8 (): bool
45
+ private function usingMysql8 ($ adapter = null ): bool
46
46
{
47
- return version_compare ($ this ->adapter ->getAttribute (\PDO ::ATTR_SERVER_VERSION ), '8.0.0 ' , '>= ' );
47
+ return version_compare (( $ adapter ?? $ this ->adapter ) ->getAttribute (\PDO ::ATTR_SERVER_VERSION ), '8.0.0 ' , '>= ' );
48
48
}
49
49
50
50
public function testConnection ()
@@ -408,7 +408,8 @@ public function testCreateTableAndInheritDefaultCollation()
408
408
->save ();
409
409
$ this ->assertTrue ($ adapter ->hasTable ('table_with_default_collation ' ));
410
410
$ row = $ adapter ->fetchRow (sprintf ("SHOW TABLE STATUS WHERE Name = '%s' " , 'table_with_default_collation ' ));
411
- $ this ->assertEquals ('utf8_unicode_ci ' , $ row ['Collation ' ]);
411
+ $ collation = $ this ->usingMysql8 ($ adapter ) ? 'utf8mb3 ' : 'utf8 ' ;
412
+ $ this ->assertEquals ($ collation . '_unicode_ci ' , $ row ['Collation ' ]);
412
413
}
413
414
414
415
public function testCreateTableWithLatin1Collate ()
@@ -771,7 +772,8 @@ public function testAddStringColumnWithCustomCollation()
771
772
$ table ->addColumn ('string_collation_default ' , 'string ' , [])->save ();
772
773
$ table ->addColumn ('string_collation_custom ' , 'string ' , ['collation ' => 'utf8mb4_unicode_ci ' ])->save ();
773
774
$ rows = $ this ->adapter ->fetchAll ('SHOW FULL COLUMNS FROM table_custom_collation ' );
774
- $ this ->assertEquals ('utf8_general_ci ' , $ rows [1 ]['Collation ' ]);
775
+ $ collation = $ this ->usingMysql8 () ? 'utf8mb3 ' : 'utf8 ' ;
776
+ $ this ->assertEquals ($ collation . '_general_ci ' , $ rows [1 ]['Collation ' ]);
775
777
$ this ->assertEquals ('utf8mb4_unicode_ci ' , $ rows [2 ]['Collation ' ]);
776
778
}
777
779
0 commit comments