2020
2121class SchemaTest extends TestCase
2222{
23+ private const COLL_WITH_COLLATION = 'collection_with_collation ' ;
24+
2325 public function tearDown (): void
2426 {
2527 $ database = $ this ->getConnection ('mongodb ' )->getDatabase ();
2628 assert ($ database instanceof Database);
2729 $ database ->dropCollection ('newcollection ' );
2830 $ database ->dropCollection ('newcollection_two ' );
31+ $ database ->dropCollection (self ::COLL_WITH_COLLATION );
2932 $ database ->dropCollection ('test_view ' );
3033
3134 parent ::tearDown ();
@@ -394,9 +397,17 @@ public function testHasColumns(): void
394397
395398 public function testGetTables ()
396399 {
400+ $ db = DB ::connection ('mongodb ' )->getDatabase ();
401+ $ db ->createCollection (self ::COLL_WITH_COLLATION , [
402+ 'collation ' => [
403+ 'locale ' => 'fr ' ,
404+ 'strength ' => 2 ,
405+ ],
406+ ]);
407+
397408 DB ::connection ('mongodb ' )->table ('newcollection ' )->insert (['test ' => 'value ' ]);
398409 DB ::connection ('mongodb ' )->table ('newcollection_two ' )->insert (['test ' => 'value ' ]);
399- DB :: connection ( ' mongodb ' )-> getDatabase () ->createCollection ('test_view ' , ['viewOn ' => 'newcollection ' ]);
410+ $ db ->createCollection ('test_view ' , ['viewOn ' => 'newcollection ' ]);
400411 $ dbName = DB ::connection ('mongodb ' )->getDatabaseName ();
401412
402413 $ tables = Schema::getTables ();
@@ -407,6 +418,7 @@ public function testGetTables()
407418 $ this ->assertArrayHasKey ('name ' , $ table );
408419 $ this ->assertArrayHasKey ('size ' , $ table );
409420 $ this ->assertArrayHasKey ('schema ' , $ table );
421+ $ this ->assertArrayHasKey ('collation ' , $ table );
410422 $ this ->assertArrayHasKey ('schema_qualified_name ' , $ table );
411423 $ this ->assertNotEquals ('test_view ' , $ table ['name ' ], 'Standard views should not be included in the result of getTables. ' );
412424
@@ -416,6 +428,10 @@ public function testGetTables()
416428 $ this ->assertEquals ($ dbName . '.newcollection ' , $ table ['schema_qualified_name ' ]);
417429 $ found = true ;
418430 }
431+
432+ if ($ table ['name ' ] === self ::COLL_WITH_COLLATION ) {
433+ $ this ->assertEquals ('l=fr;cl=0;cf=off;s=2;no=0;a=non-ignorable;mv=punct;n=0;b=0 ' , $ table ['collation ' ]);
434+ }
419435 }
420436
421437 if (! $ found ) {
0 commit comments