20
20
21
21
class SchemaTest extends TestCase
22
22
{
23
+ private const COLL_WITH_COLLATION = 'collection_with_collation ' ;
24
+ private const VIEW_WITH_COLLATION = 'view_with_collation ' ;
25
+
23
26
public function tearDown (): void
24
27
{
25
28
$ database = $ this ->getConnection ('mongodb ' )->getDatabase ();
26
29
assert ($ database instanceof Database);
27
30
$ database ->dropCollection ('newcollection ' );
28
31
$ database ->dropCollection ('newcollection_two ' );
32
+ $ database ->dropCollection (self ::COLL_WITH_COLLATION );
29
33
$ database ->dropCollection ('test_view ' );
30
34
31
35
parent ::tearDown ();
@@ -394,9 +398,17 @@ public function testHasColumns(): void
394
398
395
399
public function testGetTables ()
396
400
{
401
+ $ db = DB ::connection ('mongodb ' )->getDatabase ();
402
+ $ db ->createCollection (self ::COLL_WITH_COLLATION , [
403
+ 'collation ' => [
404
+ 'locale ' => 'fr ' ,
405
+ 'strength ' => 2 ,
406
+ ],
407
+ ]);
408
+
397
409
DB ::connection ('mongodb ' )->table ('newcollection ' )->insert (['test ' => 'value ' ]);
398
410
DB ::connection ('mongodb ' )->table ('newcollection_two ' )->insert (['test ' => 'value ' ]);
399
- DB :: connection ( ' mongodb ' )-> getDatabase () ->createCollection ('test_view ' , ['viewOn ' => 'newcollection ' ]);
411
+ $ db ->createCollection ('test_view ' , ['viewOn ' => 'newcollection ' ]);
400
412
$ dbName = DB ::connection ('mongodb ' )->getDatabaseName ();
401
413
402
414
$ tables = Schema::getTables ();
@@ -407,6 +419,7 @@ public function testGetTables()
407
419
$ this ->assertArrayHasKey ('name ' , $ table );
408
420
$ this ->assertArrayHasKey ('size ' , $ table );
409
421
$ this ->assertArrayHasKey ('schema ' , $ table );
422
+ $ this ->assertArrayHasKey ('collation ' , $ table );
410
423
$ this ->assertArrayHasKey ('schema_qualified_name ' , $ table );
411
424
$ this ->assertNotEquals ('test_view ' , $ table ['name ' ], 'Standard views should not be included in the result of getTables. ' );
412
425
@@ -416,6 +429,10 @@ public function testGetTables()
416
429
$ this ->assertEquals ($ dbName . '.newcollection ' , $ table ['schema_qualified_name ' ]);
417
430
$ found = true ;
418
431
}
432
+
433
+ if ($ table ['name ' ] === self ::COLL_WITH_COLLATION ) {
434
+ $ this ->assertEquals ('l=fr;cl=0;cf=off;s=2;no=0;a=non-ignorable;mv=punct;n=0;b=0 ' , $ table ['collation ' ]);
435
+ }
419
436
}
420
437
421
438
if (! $ found ) {
0 commit comments