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