File tree Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Original file line number Diff line number Diff line change 11
11
use MongoDB \Driver \WriteConcern ;
12
12
use MongoDB \Model \BSONArray ;
13
13
use MongoDB \Model \BSONDocument ;
14
+ use MongoDB \Tests \SpecTests \DocumentsMatchConstraint ;
14
15
use PHPUnit \Framework \TestCase as BaseTestCase ;
15
16
use ReflectionClass ;
16
17
use stdClass ;
@@ -96,27 +97,7 @@ protected static function getDatabaseName(): string
96
97
*/
97
98
public function assertMatchesDocument ($ expectedDocument , $ actualDocument ): void
98
99
{
99
- $ normalizedExpectedDocument = $ this ->normalizeBSON ($ expectedDocument );
100
- $ normalizedActualDocument = $ this ->normalizeBSON ($ actualDocument );
101
-
102
- $ extraKeys = [];
103
-
104
- /* Avoid unsetting fields while we're iterating on the ArrayObject to
105
- * work around https://bugs.php.net/bug.php?id=70246 */
106
- foreach ($ normalizedActualDocument as $ key => $ value ) {
107
- if (! $ normalizedExpectedDocument ->offsetExists ($ key )) {
108
- $ extraKeys [] = $ key ;
109
- }
110
- }
111
-
112
- foreach ($ extraKeys as $ key ) {
113
- $ normalizedActualDocument ->offsetUnset ($ key );
114
- }
115
-
116
- $ this ->assertEquals (
117
- Document::fromPHP ($ normalizedExpectedDocument )->toRelaxedExtendedJSON (),
118
- Document::fromPHP ($ normalizedActualDocument )->toRelaxedExtendedJSON (),
119
- );
100
+ (new DocumentsMatchConstraint ($ expectedDocument , true , true ))->evaluate ($ actualDocument );
120
101
}
121
102
122
103
/**
You can’t perform that action at this time.
0 commit comments