From 5560092d3d55177fdb91198678f0296343a6628c Mon Sep 17 00:00:00 2001 From: sergey Date: Fri, 25 Jan 2019 16:47:40 +0300 Subject: [PATCH 1/2] Add support set in fields stdClass in Structure::prepareToStore --- src/Structure.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Structure.php b/src/Structure.php index 33648eb..ea9bcb1 100644 --- a/src/Structure.php +++ b/src/Structure.php @@ -399,6 +399,11 @@ public static function prepareToStore($value) return $value->toArray(); } + // stdClass + if ($value instanceof \stdClass) { + return $value; + } + // other objects convert to array return (array) $value; } From 216748c014500289f1ee9a6736a9db0f9c60d3c6 Mon Sep 17 00:00:00 2001 From: sergey Date: Fri, 25 Jan 2019 18:23:36 +0300 Subject: [PATCH 2/2] fixed test --- tests/DocumentAddToSetTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/DocumentAddToSetTest.php b/tests/DocumentAddToSetTest.php index 3cb79e5..eb100ee 100644 --- a/tests/DocumentAddToSetTest.php +++ b/tests/DocumentAddToSetTest.php @@ -46,7 +46,7 @@ public function fieldValuesDataProvider() null, 'string1', 'string2', array('string1', 'string2'), ), 'newField_emptyStdclass' => array( - null, $stdClass, $stdClass, array(array()), + null, $stdClass, $stdClass, array($stdClass), ), 'newField_MongoId' => array( null, $mongoId1, $mongoId2, array($mongoId1, $mongoId2), @@ -83,7 +83,7 @@ public function fieldValuesDataProvider() 'string2', 'string1', 'string2', array('string2', 'string1'), ), 'scalarField_emptyStdclass' => array( - 2, $stdClass, $stdClass, array(2, array()), + 2, $stdClass, $stdClass, array(2, $stdClass), ), 'scalarField_MongoId' => array( 2, $mongoId1, $mongoId2, array(2, $mongoId1, $mongoId2), @@ -125,7 +125,7 @@ public function fieldValuesDataProvider() array('string2', 'string4'), 'string1', 'string2', array('string2', 'string4', 'string1'), ), 'setField_emptyStdclass' => array( - array(2, 4), $stdClass, $stdClass, array(2, 4, array()), + array(2, 4), $stdClass, $stdClass, array(2, 4, $stdClass), ), 'setField_MongoId' => array( array(2, 4), $mongoId1, $mongoId2, array(2, 4, $mongoId1, $mongoId2), @@ -280,4 +280,4 @@ public function testAddToSetOnSubDocumentField() { true ); } -} \ No newline at end of file +}