4
4
5
5
namespace Doctrine \ODM \MongoDB \Tests \Functional ;
6
6
7
+ use Doctrine \ODM \MongoDB \DocumentManager ;
7
8
use Doctrine \ODM \MongoDB \MongoDBException ;
8
9
use Doctrine \ODM \MongoDB \Tests \BaseTestCase ;
9
10
use Documents \Sharded \ShardedByUser ;
@@ -31,7 +32,7 @@ public function testEnsureShardingForNewCollection(): void
31
32
32
33
$ collection = $ this ->dm ->getDocumentCollection ($ class );
33
34
$ 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 ];
35
36
36
37
self ::assertCount (2 , $ indexes );
37
38
self ::assertSame (['k ' => 1 ], $ indexes [1 ]['key ' ]);
@@ -45,7 +46,7 @@ public function testEnsureShardingForNewCollectionWithoutCreatingIndexes(): void
45
46
46
47
$ collection = $ this ->dm ->getDocumentCollection ($ class );
47
48
$ 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 ];
49
50
50
51
self ::assertCount (2 , $ indexes );
51
52
self ::assertSame (['k ' => 1 ], $ indexes [1 ]['key ' ]);
@@ -64,7 +65,7 @@ public function testEnsureShardingForCollectionWithDocuments(): void
64
65
$ this ->dm ->getSchemaManager ()->ensureDocumentSharding ($ class );
65
66
66
67
$ 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 ];
68
69
69
70
self ::assertTrue ($ stats ['sharded ' ]);
70
71
}
@@ -83,7 +84,7 @@ public function testEnsureShardingForCollectionWithDocumentsThrowsIndexError():
83
84
$ this ->dm ->getSchemaManager ()->ensureDocumentSharding ($ class );
84
85
85
86
$ 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 ];
87
88
88
89
self ::assertFalse ($ stats ['sharded ' ]);
89
90
}
@@ -97,7 +98,7 @@ public function testEnsureShardingForCollectionWithShardingEnabled(): void
97
98
$ this ->dm ->getSchemaManager ()->ensureDocumentSharding (ShardedOne::class);
98
99
99
100
$ 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 ];
101
102
102
103
self ::assertTrue ($ stats ['sharded ' ]);
103
104
}
@@ -110,7 +111,7 @@ public function testEnsureDocumentShardingWithShardByReference(): void
110
111
$ this ->dm ->getSchemaManager ()->ensureDocumentSharding ($ class );
111
112
112
113
$ 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 ];
114
115
$ indexes = iterator_to_array ($ collection ->listIndexes ());
115
116
116
117
self ::assertTrue ($ stats ['sharded ' ]);
0 commit comments