Skip to content

Commit 3558cfa

Browse files
derickrjmikola
authored andcommitted
Compare all arrays of documents by setting the typemap for documents to 'array'.
1 parent b419611 commit 3558cfa

14 files changed

+55
-49
lines changed

tests/Collection/BulkWriteFunctionalTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testInserts()
3535
array('_id' => $insertedIds[1], 'x' => 22),
3636
);
3737

38-
$this->assertEquals($expected, $this->collection->find()->toArray());
38+
$this->assertSameDocuments($expected, $this->collection->find());
3939
}
4040

4141
public function testUpdates()
@@ -69,7 +69,7 @@ public function testUpdates()
6969
array('_id' => $upsertedIds[3], 'x' => 67),
7070
);
7171

72-
$this->assertEquals($expected, $this->collection->find()->toArray());
72+
$this->assertSameDocuments($expected, $this->collection->find());
7373
}
7474

7575
public function testDeletes()
@@ -89,7 +89,7 @@ public function testDeletes()
8989
array('_id' => 2, 'x' => 22),
9090
);
9191

92-
$this->assertEquals($expected, $this->collection->find()->toArray());
92+
$this->assertSameDocuments($expected, $this->collection->find());
9393
}
9494

9595
public function testMixedOrderedOperations()
@@ -123,7 +123,7 @@ public function testMixedOrderedOperations()
123123
array('_id' => 4, 'x' => 44),
124124
);
125125

126-
$this->assertEquals($expected, $this->collection->find()->toArray());
126+
$this->assertSameDocuments($expected, $this->collection->find());
127127
}
128128

129129
/**

tests/Collection/CrudSpec/AggregateFunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public function testAggregateWithMultipleStages()
3232
);
3333

3434
$expected = array(
35-
array('_id' => 2, 'x' => 22),
36-
array('_id' => 3, 'x' => 33),
35+
(object) array('_id' => 2, 'x' => 22),
36+
(object) array('_id' => 3, 'x' => 33),
3737
);
3838

3939
// Use iterator_to_array() here since aggregate() may return an ArrayIterator
@@ -64,7 +64,7 @@ public function testAggregateWithOut()
6464
array('_id' => 3, 'x' => 33),
6565
);
6666

67-
$this->assertEquals($expected, $outputCollection->find()->toArray());
67+
$this->assertSameDocuments($expected, $outputCollection->find());
6868

6969
// Manually clean up our output collection
7070
$this->dropCollectionIfItExists($outputCollection);

tests/Collection/CrudSpec/DeleteManyFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testDeleteManyWhenManyDocumentsMatch()
2727
array('_id' => 1, 'x' => 11),
2828
);
2929

30-
$this->assertSame($expected, $this->collection->find()->toArray());
30+
$this->assertSameDocuments($expected, $this->collection->find());
3131
}
3232

3333
public function testDeleteManyWhenNoDocumentsMatch()
@@ -43,6 +43,6 @@ public function testDeleteManyWhenNoDocumentsMatch()
4343
array('_id' => 3, 'x' => 33),
4444
);
4545

46-
$this->assertSame($expected, $this->collection->find()->toArray());
46+
$this->assertSameDocuments($expected, $this->collection->find());
4747
}
4848
}

tests/Collection/CrudSpec/DeleteOneFunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testDeleteOneWhenManyDocumentsMatch()
2828
array('_id' => 3, 'x' => 33),
2929
);
3030

31-
$this->assertSame($expected, $this->collection->find()->toArray());
31+
$this->assertSameDocuments($expected, $this->collection->find());
3232
}
3333

3434
public function testDeleteOneWhenOneDocumentMatches()
@@ -43,7 +43,7 @@ public function testDeleteOneWhenOneDocumentMatches()
4343
array('_id' => 3, 'x' => 33),
4444
);
4545

46-
$this->assertSame($expected, $this->collection->find()->toArray());
46+
$this->assertSameDocuments($expected, $this->collection->find());
4747
}
4848

4949
public function testDeleteOneWhenNoDocumentsMatch()
@@ -59,6 +59,6 @@ public function testDeleteOneWhenNoDocumentsMatch()
5959
array('_id' => 3, 'x' => 33),
6060
);
6161

62-
$this->assertSame($expected, $this->collection->find()->toArray());
62+
$this->assertSameDocuments($expected, $this->collection->find());
6363
}
6464
}

tests/Collection/CrudSpec/FindFunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testFindWithFilter()
2424
array('_id' => 1, 'x' => 11),
2525
);
2626

27-
$this->assertSame($expected, $this->collection->find($filter)->toArray());
27+
$this->assertSameDocuments($expected, $this->collection->find($filter));
2828
}
2929

3030
public function testFindWithFilterSortSkipAndLimit()
@@ -40,7 +40,7 @@ public function testFindWithFilterSortSkipAndLimit()
4040
array('_id' => 5, 'x' => 55),
4141
);
4242

43-
$this->assertSame($expected, $this->collection->find($filter, $options)->toArray());
43+
$this->assertSameDocuments($expected, $this->collection->find($filter, $options));
4444
}
4545

4646
public function testFindWithLimitSortAndBatchSize()
@@ -59,6 +59,6 @@ public function testFindWithLimitSortAndBatchSize()
5959
array('_id' => 4, 'x' => 44),
6060
);
6161

62-
$this->assertSame($expected, $this->collection->find($filter, $options)->toArray());
62+
$this->assertSameDocuments($expected, $this->collection->find($filter, $options));
6363
}
6464
}

tests/Collection/CrudSpec/FindOneAndDeleteFunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testFindOneAndDeleteWhenManyDocumentsMatch()
3232
array('_id' => 3, 'x' => 33),
3333
);
3434

35-
$this->assertSame($expected, $this->collection->find()->toArray());
35+
$this->assertSameDocuments($expected, $this->collection->find());
3636
}
3737

3838
public function testFindOneAndDeleteWhenOneDocumentMatches()
@@ -51,7 +51,7 @@ public function testFindOneAndDeleteWhenOneDocumentMatches()
5151
array('_id' => 3, 'x' => 33),
5252
);
5353

54-
$this->assertSame($expected, $this->collection->find()->toArray());
54+
$this->assertSameDocuments($expected, $this->collection->find());
5555
}
5656

5757
public function testFindOneAndDeleteWhenNoDocumentsMatch()
@@ -71,6 +71,6 @@ public function testFindOneAndDeleteWhenNoDocumentsMatch()
7171
array('_id' => 3, 'x' => 33),
7272
);
7373

74-
$this->assertSame($expected, $this->collection->find()->toArray());
74+
$this->assertSameDocuments($expected, $this->collection->find());
7575
}
7676
}

tests/Collection/CrudSpec/FindOneAndReplaceFunctionalTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentBefo
3737
array('_id' => 3, 'x' => 33),
3838
);
3939

40-
$this->assertSame($expected, $this->collection->find()->toArray());
40+
$this->assertSameDocuments($expected, $this->collection->find());
4141
}
4242

4343
public function testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfterModification()
@@ -59,7 +59,7 @@ public function testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfte
5959
array('_id' => 3, 'x' => 33),
6060
);
6161

62-
$this->assertSame($expected, $this->collection->find()->toArray());
62+
$this->assertSameDocuments($expected, $this->collection->find());
6363
}
6464

6565
public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBeforeModification()
@@ -80,7 +80,7 @@ public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBefo
8080
array('_id' => 3, 'x' => 33),
8181
);
8282

83-
$this->assertSame($expected, $this->collection->find()->toArray());
83+
$this->assertSameDocuments($expected, $this->collection->find());
8484
}
8585

8686
public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfterModification()
@@ -102,7 +102,7 @@ public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfte
102102
array('_id' => 3, 'x' => 33),
103103
);
104104

105-
$this->assertSame($expected, $this->collection->find()->toArray());
105+
$this->assertSameDocuments($expected, $this->collection->find());
106106
}
107107

108108
public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBeforeModification()
@@ -123,7 +123,7 @@ public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBefore
123123
array('_id' => 3, 'x' => 33),
124124
);
125125

126-
$this->assertSame($expected, $this->collection->find()->toArray());
126+
$this->assertSameDocuments($expected, $this->collection->find());
127127
}
128128

129129
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
@@ -147,7 +147,7 @@ public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocu
147147
array('_id' => 4, 'x' => 44),
148148
);
149149

150-
$this->assertSame($expected, $this->collection->find()->toArray());
150+
$this->assertSameDocuments($expected, $this->collection->find());
151151
}
152152

153153
public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterModification()
@@ -169,7 +169,7 @@ public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterM
169169
array('_id' => 3, 'x' => 33),
170170
);
171171

172-
$this->assertSame($expected, $this->collection->find()->toArray());
172+
$this->assertSameDocuments($expected, $this->collection->find());
173173
}
174174

175175
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
@@ -194,6 +194,6 @@ public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocu
194194
array('_id' => 4, 'x' => 44),
195195
);
196196

197-
$this->assertSame($expected, $this->collection->find()->toArray());
197+
$this->assertSameDocuments($expected, $this->collection->find());
198198
}
199199
}

tests/Collection/CrudSpec/FindOneAndUpdateFunctionalTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentBefor
3737
array('_id' => 3, 'x' => 33),
3838
);
3939

40-
$this->assertSame($expected, $this->collection->find()->toArray());
40+
$this->assertSameDocuments($expected, $this->collection->find());
4141
}
4242

4343
public function testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfterModification()
@@ -59,7 +59,7 @@ public function testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfter
5959
array('_id' => 3, 'x' => 33),
6060
);
6161

62-
$this->assertSame($expected, $this->collection->find()->toArray());
62+
$this->assertSameDocuments($expected, $this->collection->find());
6363
}
6464

6565
public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBeforeModification()
@@ -80,7 +80,7 @@ public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBefor
8080
array('_id' => 3, 'x' => 33),
8181
);
8282

83-
$this->assertSame($expected, $this->collection->find()->toArray());
83+
$this->assertSameDocuments($expected, $this->collection->find());
8484
}
8585

8686
public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfterModification()
@@ -102,7 +102,7 @@ public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfter
102102
array('_id' => 3, 'x' => 33),
103103
);
104104

105-
$this->assertSame($expected, $this->collection->find()->toArray());
105+
$this->assertSameDocuments($expected, $this->collection->find());
106106
}
107107

108108
public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeModification()
@@ -123,7 +123,7 @@ public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeM
123123
array('_id' => 3, 'x' => 33),
124124
);
125125

126-
$this->assertSame($expected, $this->collection->find()->toArray());
126+
$this->assertSameDocuments($expected, $this->collection->find());
127127
}
128128

129129
public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
@@ -146,7 +146,7 @@ public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocum
146146
array('_id' => 4, 'x' => 1),
147147
);
148148

149-
$this->assertSame($expected, $this->collection->find()->toArray());
149+
$this->assertSameDocuments($expected, $this->collection->find());
150150
}
151151

152152
public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterModification()
@@ -168,7 +168,7 @@ public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterMo
168168
array('_id' => 3, 'x' => 33),
169169
);
170170

171-
$this->assertSame($expected, $this->collection->find()->toArray());
171+
$this->assertSameDocuments($expected, $this->collection->find());
172172
}
173173

174174
public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
@@ -192,6 +192,6 @@ public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocum
192192
array('_id' => 4, 'x' => 1),
193193
);
194194

195-
$this->assertSame($expected, $this->collection->find()->toArray());
195+
$this->assertSameDocuments($expected, $this->collection->find());
196196
}
197197
}

tests/Collection/CrudSpec/InsertManyFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function testInsertManyWithNonexistentDocuments()
3333
array('_id' => 3, 'x' => 33),
3434
);
3535

36-
$this->assertSame($expected, $this->collection->find()->toArray());
36+
$this->assertSameDocuments($expected, $this->collection->find());
3737
}
3838
}

tests/Collection/CrudSpec/InsertOneFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function testInsertOneWithANonexistentDocument()
2929
array('_id' => 2, 'x' => 22),
3030
);
3131

32-
$this->assertSame($expected, $this->collection->find()->toArray());
32+
$this->assertSameDocuments($expected, $this->collection->find());
3333
}
3434
}

tests/Collection/CrudSpec/ReplaceOneFunctionalTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testReplaceOneWhenManyDocumentsMatch()
3535
array('_id' => 3, 'x' => 33),
3636
);
3737

38-
$this->assertSame($expected, $this->collection->find()->toArray());
38+
$this->assertSameDocuments($expected, $this->collection->find());
3939
}
4040

4141
public function testReplaceOneWhenOneDocumentMatches()
@@ -53,7 +53,7 @@ public function testReplaceOneWhenOneDocumentMatches()
5353
array('_id' => 3, 'x' => 33),
5454
);
5555

56-
$this->assertSame($expected, $this->collection->find()->toArray());
56+
$this->assertSameDocuments($expected, $this->collection->find());
5757
}
5858

5959
public function testReplaceOneWhenNoDocumentsMatch()
@@ -71,7 +71,7 @@ public function testReplaceOneWhenNoDocumentsMatch()
7171
array('_id' => 3, 'x' => 33),
7272
);
7373

74-
$this->assertSame($expected, $this->collection->find()->toArray());
74+
$this->assertSameDocuments($expected, $this->collection->find());
7575
}
7676

7777
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified()
@@ -92,7 +92,7 @@ public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified()
9292
array('_id' => 4, 'x' => 1),
9393
);
9494

95-
$this->assertSame($expected, $this->collection->find()->toArray());
95+
$this->assertSameDocuments($expected, $this->collection->find());
9696
}
9797

9898
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified()
@@ -114,6 +114,6 @@ public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified
114114
array('_id' => 4, 'x' => 1),
115115
);
116116

117-
$this->assertSame($expected, $this->collection->find()->toArray());
117+
$this->assertSameDocuments($expected, $this->collection->find());
118118
}
119119
}

tests/Collection/CrudSpec/UpdateManyFunctionalTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testUpdateManyWhenManyDocumentsMatch()
3535
array('_id' => 3, 'x' => 34),
3636
);
3737

38-
$this->assertSame($expected, $this->collection->find()->toArray());
38+
$this->assertSameDocuments($expected, $this->collection->find());
3939
}
4040

4141
public function testUpdateManyWhenOneDocumentMatches()
@@ -53,7 +53,7 @@ public function testUpdateManyWhenOneDocumentMatches()
5353
array('_id' => 3, 'x' => 33),
5454
);
5555

56-
$this->assertSame($expected, $this->collection->find()->toArray());
56+
$this->assertSameDocuments($expected, $this->collection->find());
5757
}
5858

5959
public function testUpdateManyWhenNoDocumentsMatch()
@@ -71,7 +71,7 @@ public function testUpdateManyWhenNoDocumentsMatch()
7171
array('_id' => 3, 'x' => 33),
7272
);
7373

74-
$this->assertSame($expected, $this->collection->find()->toArray());
74+
$this->assertSameDocuments($expected, $this->collection->find());
7575
}
7676

7777
public function testUpdateManyWithUpsertWhenNoDocumentsMatch()
@@ -92,6 +92,6 @@ public function testUpdateManyWithUpsertWhenNoDocumentsMatch()
9292
array('_id' => 4, 'x' => 1),
9393
);
9494

95-
$this->assertSame($expected, $this->collection->find()->toArray());
95+
$this->assertSameDocuments($expected, $this->collection->find());
9696
}
9797
}

0 commit comments

Comments
 (0)