44
55namespace Doctrine \ODM \MongoDB \Tests \Functional ;
66
7+ use Doctrine \ODM \MongoDB \DocumentManager ;
78use Doctrine \ODM \MongoDB \MongoDBException ;
89use Doctrine \ODM \MongoDB \Tests \BaseTestCase ;
910use Documents \Sharded \ShardedByUser ;
@@ -31,7 +32,7 @@ public function testEnsureShardingForNewCollection(): void
3132
3233 $ collection = $ this ->dm ->getDocumentCollection ($ class );
3334 $ indexes = iterator_to_array ($ collection ->listIndexes ());
34- $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()])->toArray ()[0 ];
35+ $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()], [ ' typeMap ' => DocumentManager:: CLIENT_TYPEMAP ] )->toArray ()[0 ];
3536
3637 self ::assertCount (2 , $ indexes );
3738 self ::assertSame (['k ' => 1 ], $ indexes [1 ]['key ' ]);
@@ -45,7 +46,7 @@ public function testEnsureShardingForNewCollectionWithoutCreatingIndexes(): void
4546
4647 $ collection = $ this ->dm ->getDocumentCollection ($ class );
4748 $ indexes = iterator_to_array ($ collection ->listIndexes ());
48- $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()])->toArray ()[0 ];
49+ $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()], [ ' typeMap ' => DocumentManager:: CLIENT_TYPEMAP ] )->toArray ()[0 ];
4950
5051 self ::assertCount (2 , $ indexes );
5152 self ::assertSame (['k ' => 1 ], $ indexes [1 ]['key ' ]);
@@ -64,7 +65,7 @@ public function testEnsureShardingForCollectionWithDocuments(): void
6465 $ this ->dm ->getSchemaManager ()->ensureDocumentSharding ($ class );
6566
6667 $ collection = $ this ->dm ->getDocumentCollection ($ class );
67- $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()])->toArray ()[0 ];
68+ $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()], [ ' typeMap ' => DocumentManager:: CLIENT_TYPEMAP ] )->toArray ()[0 ];
6869
6970 self ::assertTrue ($ stats ['sharded ' ]);
7071 }
@@ -83,7 +84,7 @@ public function testEnsureShardingForCollectionWithDocumentsThrowsIndexError():
8384 $ this ->dm ->getSchemaManager ()->ensureDocumentSharding ($ class );
8485
8586 $ collection = $ this ->dm ->getDocumentCollection ($ class );
86- $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()])->toArray ()[0 ];
87+ $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()], [ ' typeMap ' => DocumentManager:: CLIENT_TYPEMAP ] )->toArray ()[0 ];
8788
8889 self ::assertFalse ($ stats ['sharded ' ]);
8990 }
@@ -97,7 +98,7 @@ public function testEnsureShardingForCollectionWithShardingEnabled(): void
9798 $ this ->dm ->getSchemaManager ()->ensureDocumentSharding (ShardedOne::class);
9899
99100 $ collection = $ this ->dm ->getDocumentCollection ($ class );
100- $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()])->toArray ()[0 ];
101+ $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()], [ ' typeMap ' => DocumentManager:: CLIENT_TYPEMAP ] )->toArray ()[0 ];
101102
102103 self ::assertTrue ($ stats ['sharded ' ]);
103104 }
@@ -110,7 +111,7 @@ public function testEnsureDocumentShardingWithShardByReference(): void
110111 $ this ->dm ->getSchemaManager ()->ensureDocumentSharding ($ class );
111112
112113 $ collection = $ this ->dm ->getDocumentCollection ($ class );
113- $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()])->toArray ()[0 ];
114+ $ stats = $ this ->dm ->getDocumentDatabase ($ class )->command (['collstats ' => $ collection ->getCollectionName ()], [ ' typeMap ' => DocumentManager:: CLIENT_TYPEMAP ] )->toArray ()[0 ];
114115 $ indexes = iterator_to_array ($ collection ->listIndexes ());
115116
116117 self ::assertTrue ($ stats ['sharded ' ]);
0 commit comments