Commit 3558cfa8 authored by Derick Rethans's avatar Derick Rethans Committed by Jeremy Mikola

Compare all arrays of documents by setting the typemap for documents to 'array'.

parent b419611f
...@@ -35,7 +35,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase ...@@ -35,7 +35,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
array('_id' => $insertedIds[1], 'x' => 22), array('_id' => $insertedIds[1], 'x' => 22),
); );
$this->assertEquals($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdates() public function testUpdates()
...@@ -69,7 +69,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase ...@@ -69,7 +69,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
array('_id' => $upsertedIds[3], 'x' => 67), array('_id' => $upsertedIds[3], 'x' => 67),
); );
$this->assertEquals($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testDeletes() public function testDeletes()
...@@ -89,7 +89,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase ...@@ -89,7 +89,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
array('_id' => 2, 'x' => 22), array('_id' => 2, 'x' => 22),
); );
$this->assertEquals($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testMixedOrderedOperations() public function testMixedOrderedOperations()
...@@ -123,7 +123,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase ...@@ -123,7 +123,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 44), array('_id' => 4, 'x' => 44),
); );
$this->assertEquals($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
/** /**
......
...@@ -32,8 +32,8 @@ class AggregateFunctionalTest extends FunctionalTestCase ...@@ -32,8 +32,8 @@ class AggregateFunctionalTest extends FunctionalTestCase
); );
$expected = array( $expected = array(
array('_id' => 2, 'x' => 22), (object) array('_id' => 2, 'x' => 22),
array('_id' => 3, 'x' => 33), (object) array('_id' => 3, 'x' => 33),
); );
// Use iterator_to_array() here since aggregate() may return an ArrayIterator // Use iterator_to_array() here since aggregate() may return an ArrayIterator
...@@ -64,7 +64,7 @@ class AggregateFunctionalTest extends FunctionalTestCase ...@@ -64,7 +64,7 @@ class AggregateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertEquals($expected, $outputCollection->find()->toArray()); $this->assertSameDocuments($expected, $outputCollection->find());
// Manually clean up our output collection // Manually clean up our output collection
$this->dropCollectionIfItExists($outputCollection); $this->dropCollectionIfItExists($outputCollection);
......
...@@ -27,7 +27,7 @@ class DeleteManyFunctionalTest extends FunctionalTestCase ...@@ -27,7 +27,7 @@ class DeleteManyFunctionalTest extends FunctionalTestCase
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testDeleteManyWhenNoDocumentsMatch() public function testDeleteManyWhenNoDocumentsMatch()
...@@ -43,6 +43,6 @@ class DeleteManyFunctionalTest extends FunctionalTestCase ...@@ -43,6 +43,6 @@ class DeleteManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -28,7 +28,7 @@ class DeleteOneFunctionalTest extends FunctionalTestCase ...@@ -28,7 +28,7 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testDeleteOneWhenOneDocumentMatches() public function testDeleteOneWhenOneDocumentMatches()
...@@ -43,7 +43,7 @@ class DeleteOneFunctionalTest extends FunctionalTestCase ...@@ -43,7 +43,7 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testDeleteOneWhenNoDocumentsMatch() public function testDeleteOneWhenNoDocumentsMatch()
...@@ -59,6 +59,6 @@ class DeleteOneFunctionalTest extends FunctionalTestCase ...@@ -59,6 +59,6 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -24,7 +24,7 @@ class FindFunctionalTest extends FunctionalTestCase ...@@ -24,7 +24,7 @@ class FindFunctionalTest extends FunctionalTestCase
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
); );
$this->assertSame($expected, $this->collection->find($filter)->toArray()); $this->assertSameDocuments($expected, $this->collection->find($filter));
} }
public function testFindWithFilterSortSkipAndLimit() public function testFindWithFilterSortSkipAndLimit()
...@@ -40,7 +40,7 @@ class FindFunctionalTest extends FunctionalTestCase ...@@ -40,7 +40,7 @@ class FindFunctionalTest extends FunctionalTestCase
array('_id' => 5, 'x' => 55), array('_id' => 5, 'x' => 55),
); );
$this->assertSame($expected, $this->collection->find($filter, $options)->toArray()); $this->assertSameDocuments($expected, $this->collection->find($filter, $options));
} }
public function testFindWithLimitSortAndBatchSize() public function testFindWithLimitSortAndBatchSize()
...@@ -59,6 +59,6 @@ class FindFunctionalTest extends FunctionalTestCase ...@@ -59,6 +59,6 @@ class FindFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 44), array('_id' => 4, 'x' => 44),
); );
$this->assertSame($expected, $this->collection->find($filter, $options)->toArray()); $this->assertSameDocuments($expected, $this->collection->find($filter, $options));
} }
} }
...@@ -32,7 +32,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase ...@@ -32,7 +32,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndDeleteWhenOneDocumentMatches() public function testFindOneAndDeleteWhenOneDocumentMatches()
...@@ -51,7 +51,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase ...@@ -51,7 +51,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndDeleteWhenNoDocumentsMatch() public function testFindOneAndDeleteWhenNoDocumentsMatch()
...@@ -71,6 +71,6 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase ...@@ -71,6 +71,6 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -37,7 +37,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -37,7 +37,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfterModification() public function testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfterModification()
...@@ -59,7 +59,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -59,7 +59,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBeforeModification() public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBeforeModification()
...@@ -80,7 +80,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -80,7 +80,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfterModification() public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfterModification()
...@@ -102,7 +102,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -102,7 +102,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBeforeModification() public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBeforeModification()
...@@ -123,7 +123,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -123,7 +123,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification() public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
...@@ -147,7 +147,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -147,7 +147,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 44), array('_id' => 4, 'x' => 44),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterModification() public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterModification()
...@@ -169,7 +169,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -169,7 +169,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification() public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
...@@ -194,6 +194,6 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -194,6 +194,6 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 44), array('_id' => 4, 'x' => 44),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -37,7 +37,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -37,7 +37,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfterModification() public function testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfterModification()
...@@ -59,7 +59,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -59,7 +59,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBeforeModification() public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBeforeModification()
...@@ -80,7 +80,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -80,7 +80,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfterModification() public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfterModification()
...@@ -102,7 +102,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -102,7 +102,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeModification() public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeModification()
...@@ -123,7 +123,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -123,7 +123,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification() public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
...@@ -146,7 +146,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -146,7 +146,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1), array('_id' => 4, 'x' => 1),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterModification() public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterModification()
...@@ -168,7 +168,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -168,7 +168,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification() public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
...@@ -192,6 +192,6 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -192,6 +192,6 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1), array('_id' => 4, 'x' => 1),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -33,6 +33,6 @@ class InsertManyFunctionalTest extends FunctionalTestCase ...@@ -33,6 +33,6 @@ class InsertManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -29,6 +29,6 @@ class InsertOneFunctionalTest extends FunctionalTestCase ...@@ -29,6 +29,6 @@ class InsertOneFunctionalTest extends FunctionalTestCase
array('_id' => 2, 'x' => 22), array('_id' => 2, 'x' => 22),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -35,7 +35,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase ...@@ -35,7 +35,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testReplaceOneWhenOneDocumentMatches() public function testReplaceOneWhenOneDocumentMatches()
...@@ -53,7 +53,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase ...@@ -53,7 +53,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testReplaceOneWhenNoDocumentsMatch() public function testReplaceOneWhenNoDocumentsMatch()
...@@ -71,7 +71,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase ...@@ -71,7 +71,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified() public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified()
...@@ -92,7 +92,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase ...@@ -92,7 +92,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1), array('_id' => 4, 'x' => 1),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified() public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified()
...@@ -114,6 +114,6 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase ...@@ -114,6 +114,6 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1), array('_id' => 4, 'x' => 1),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -35,7 +35,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase ...@@ -35,7 +35,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 34), array('_id' => 3, 'x' => 34),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdateManyWhenOneDocumentMatches() public function testUpdateManyWhenOneDocumentMatches()
...@@ -53,7 +53,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase ...@@ -53,7 +53,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdateManyWhenNoDocumentsMatch() public function testUpdateManyWhenNoDocumentsMatch()
...@@ -71,7 +71,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase ...@@ -71,7 +71,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdateManyWithUpsertWhenNoDocumentsMatch() public function testUpdateManyWithUpsertWhenNoDocumentsMatch()
...@@ -92,6 +92,6 @@ class UpdateManyFunctionalTest extends FunctionalTestCase ...@@ -92,6 +92,6 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1), array('_id' => 4, 'x' => 1),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -35,7 +35,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase ...@@ -35,7 +35,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdateOneWhenOneDocumentMatches() public function testUpdateOneWhenOneDocumentMatches()
...@@ -53,7 +53,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase ...@@ -53,7 +53,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdateOneWhenNoDocumentsMatch() public function testUpdateOneWhenNoDocumentsMatch()
...@@ -71,7 +71,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase ...@@ -71,7 +71,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33), array('_id' => 3, 'x' => 33),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
public function testUpdateOneWithUpsertWhenNoDocumentsMatch() public function testUpdateOneWithUpsertWhenNoDocumentsMatch()
...@@ -92,6 +92,6 @@ class UpdateOneFunctionalTest extends FunctionalTestCase ...@@ -92,6 +92,6 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1), array('_id' => 4, 'x' => 1),
); );
$this->assertSame($expected, $this->collection->find()->toArray()); $this->assertSameDocuments($expected, $this->collection->find());
} }
} }
...@@ -38,6 +38,12 @@ abstract class FunctionalTestCase extends TestCase ...@@ -38,6 +38,12 @@ abstract class FunctionalTestCase extends TestCase
$this->assertEquals(1, $document['ok']); $this->assertEquals(1, $document['ok']);
} }
protected function assertSameDocuments(array $expected, $cursor)
{
$cursor->setTypeMap(array('document' => 'array'));
$this->assertEquals($expected, iterator_to_array($cursor));
}
protected function getServerVersion(ReadPreference $readPreference = null) protected function getServerVersion(ReadPreference $readPreference = null)
{ {
$cursor = $this->manager->executeCommand( $cursor = $this->manager->executeCommand(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment