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
array('_id' => $insertedIds[1], 'x' => 22),
);
$this->assertEquals($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdates()
......@@ -69,7 +69,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
array('_id' => $upsertedIds[3], 'x' => 67),
);
$this->assertEquals($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testDeletes()
......@@ -89,7 +89,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
array('_id' => 2, 'x' => 22),
);
$this->assertEquals($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testMixedOrderedOperations()
......@@ -123,7 +123,7 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
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
);
$expected = array(
array('_id' => 2, 'x' => 22),
array('_id' => 3, 'x' => 33),
(object) array('_id' => 2, 'x' => 22),
(object) array('_id' => 3, 'x' => 33),
);
// Use iterator_to_array() here since aggregate() may return an ArrayIterator
......@@ -64,7 +64,7 @@ class AggregateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertEquals($expected, $outputCollection->find()->toArray());
$this->assertSameDocuments($expected, $outputCollection->find());
// Manually clean up our output collection
$this->dropCollectionIfItExists($outputCollection);
......
......@@ -27,7 +27,7 @@ class DeleteManyFunctionalTest extends FunctionalTestCase
array('_id' => 1, 'x' => 11),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testDeleteManyWhenNoDocumentsMatch()
......@@ -43,6 +43,6 @@ class DeleteManyFunctionalTest extends FunctionalTestCase
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
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testDeleteOneWhenOneDocumentMatches()
......@@ -43,7 +43,7 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testDeleteOneWhenNoDocumentsMatch()
......@@ -59,6 +59,6 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
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
array('_id' => 1, 'x' => 11),
);
$this->assertSame($expected, $this->collection->find($filter)->toArray());
$this->assertSameDocuments($expected, $this->collection->find($filter));
}
public function testFindWithFilterSortSkipAndLimit()
......@@ -40,7 +40,7 @@ class FindFunctionalTest extends FunctionalTestCase
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()
......@@ -59,6 +59,6 @@ class FindFunctionalTest extends FunctionalTestCase
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
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndDeleteWhenOneDocumentMatches()
......@@ -51,7 +51,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndDeleteWhenNoDocumentsMatch()
......@@ -71,6 +71,6 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
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
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfterModification()
......@@ -59,7 +59,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBeforeModification()
......@@ -80,7 +80,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfterModification()
......@@ -102,7 +102,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBeforeModification()
......@@ -123,7 +123,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
......@@ -147,7 +147,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 44),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterModification()
......@@ -169,7 +169,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
......@@ -194,6 +194,6 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
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
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfterModification()
......@@ -59,7 +59,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBeforeModification()
......@@ -80,7 +80,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfterModification()
......@@ -102,7 +102,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeModification()
......@@ -123,7 +123,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
......@@ -146,7 +146,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterModification()
......@@ -168,7 +168,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
......@@ -192,6 +192,6 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
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
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
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
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testReplaceOneWhenOneDocumentMatches()
......@@ -53,7 +53,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testReplaceOneWhenNoDocumentsMatch()
......@@ -71,7 +71,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified()
......@@ -92,7 +92,7 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
array('_id' => 4, 'x' => 1),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified()
......@@ -114,6 +114,6 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
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
array('_id' => 3, 'x' => 34),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdateManyWhenOneDocumentMatches()
......@@ -53,7 +53,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdateManyWhenNoDocumentsMatch()
......@@ -71,7 +71,7 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdateManyWithUpsertWhenNoDocumentsMatch()
......@@ -92,6 +92,6 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
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
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdateOneWhenOneDocumentMatches()
......@@ -53,7 +53,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdateOneWhenNoDocumentsMatch()
......@@ -71,7 +71,7 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
array('_id' => 3, 'x' => 33),
);
$this->assertSame($expected, $this->collection->find()->toArray());
$this->assertSameDocuments($expected, $this->collection->find());
}
public function testUpdateOneWithUpsertWhenNoDocumentsMatch()
......@@ -92,6 +92,6 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
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
$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)
{
$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