Commit 3028dfde authored by Jeremy Mikola's avatar Jeremy Mikola

Return documents as objects from Collection findAndModify methods

parent 02e651cb
...@@ -460,7 +460,7 @@ class Collection ...@@ -460,7 +460,7 @@ class Collection
* @see FindOneAndDelete::__construct() for supported options * @see FindOneAndDelete::__construct() for supported options
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @return array|null * @return object|null
*/ */
public function findOneAndDelete($filter, array $options = array()) public function findOneAndDelete($filter, array $options = array())
{ {
...@@ -482,7 +482,7 @@ class Collection ...@@ -482,7 +482,7 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document * @param array|object $replacement Replacement document
* @param array $options Command options * @param array $options Command options
* @return array|null * @return object|null
*/ */
public function findOneAndReplace($filter, $replacement, array $options = array()) public function findOneAndReplace($filter, $replacement, array $options = array())
{ {
...@@ -504,7 +504,7 @@ class Collection ...@@ -504,7 +504,7 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document * @param array|object $update Update to apply to the matched document
* @param array $options Command options * @param array $options Command options
* @return array|null * @return object|null
*/ */
public function findOneAndUpdate($filter, $update, array $options = array()) public function findOneAndUpdate($filter, $update, array $options = array())
{ {
......
...@@ -113,7 +113,7 @@ class FindAndModify implements Executable ...@@ -113,7 +113,7 @@ class FindAndModify implements Executable
* *
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return array|null * @return object|null
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
...@@ -143,7 +143,7 @@ class FindAndModify implements Executable ...@@ -143,7 +143,7 @@ class FindAndModify implements Executable
throw new UnexpectedValueException('findAndModify command did not return a "value" document'); throw new UnexpectedValueException('findAndModify command did not return a "value" document');
} }
return (array) $result['value']; return $result['value'];
} }
/** /**
......
...@@ -74,7 +74,7 @@ class FindOneAndDelete implements Executable ...@@ -74,7 +74,7 @@ class FindOneAndDelete implements Executable
* *
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return array|null * @return object|null
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -113,7 +113,7 @@ class FindOneAndReplace implements Executable ...@@ -113,7 +113,7 @@ class FindOneAndReplace implements Executable
* *
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return array|null * @return object|null
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -113,7 +113,7 @@ class FindOneAndUpdate implements Executable ...@@ -113,7 +113,7 @@ class FindOneAndUpdate implements Executable
* *
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return array|null * @return object|null
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -25,7 +25,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase ...@@ -25,7 +25,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndDelete($filter, $options); $document = $this->collection->findOneAndDelete($filter, $options);
$this->assertSame(array('x' => 22), $document); $this->assertEquals((object) array('x' => 22), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -44,7 +44,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase ...@@ -44,7 +44,7 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndDelete($filter, $options); $document = $this->collection->findOneAndDelete($filter, $options);
$this->assertSame(array('x' => 22), $document); $this->assertEquals((object) array('x' => 22), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
......
...@@ -29,7 +29,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -29,7 +29,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndReplace($filter, $replacement, $options); $document = $this->collection->findOneAndReplace($filter, $replacement, $options);
$this->assertSame(array('x' => 22), $document); $this->assertEquals((object) array('x' => 22), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -51,7 +51,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -51,7 +51,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndReplace($filter, $replacement, $options); $document = $this->collection->findOneAndReplace($filter, $replacement, $options);
$this->assertSame(array('x' => 32), $document); $this->assertEquals((object) array('x' => 32), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -72,7 +72,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -72,7 +72,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndReplace($filter, $replacement, $options); $document = $this->collection->findOneAndReplace($filter, $replacement, $options);
$this->assertSame(array('x' => 22), $document); $this->assertEquals((object) array('x' => 22), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -94,7 +94,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -94,7 +94,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndReplace($filter, $replacement, $options); $document = $this->collection->findOneAndReplace($filter, $replacement, $options);
$this->assertSame(array('x' => 32), $document); $this->assertEquals((object) array('x' => 32), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -185,7 +185,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase ...@@ -185,7 +185,7 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndReplace($filter, $replacement, $options); $document = $this->collection->findOneAndReplace($filter, $replacement, $options);
$this->assertSame(array('x' => 44), $document); $this->assertEquals((object) array('x' => 44), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
......
...@@ -29,7 +29,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -29,7 +29,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndUpdate($filter, $update, $options); $document = $this->collection->findOneAndUpdate($filter, $update, $options);
$this->assertSame(array('x' => 22), $document); $this->assertEquals((object) array('x' => 22), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -51,7 +51,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -51,7 +51,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndUpdate($filter, $update, $options); $document = $this->collection->findOneAndUpdate($filter, $update, $options);
$this->assertSame(array('x' => 23), $document); $this->assertEquals((object) array('x' => 23), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -72,7 +72,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -72,7 +72,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndUpdate($filter, $update, $options); $document = $this->collection->findOneAndUpdate($filter, $update, $options);
$this->assertSame(array('x' => 22), $document); $this->assertEquals((object) array('x' => 22), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -94,7 +94,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -94,7 +94,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndUpdate($filter, $update, $options); $document = $this->collection->findOneAndUpdate($filter, $update, $options);
$this->assertSame(array('x' => 23), $document); $this->assertEquals((object) array('x' => 23), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
...@@ -183,7 +183,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase ...@@ -183,7 +183,7 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
); );
$document = $this->collection->findOneAndUpdate($filter, $update, $options); $document = $this->collection->findOneAndUpdate($filter, $update, $options);
$this->assertSame(array('x' => 1), $document); $this->assertEquals((object) array('x' => 1), $document);
$expected = array( $expected = array(
array('_id' => 1, 'x' => 11), array('_id' => 1, 'x' => 11),
......
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