@@ -49,12 +49,12 @@ public function testInsertOneDocumentWithExistingId()
4949 ]);
5050
5151 $ this ->expectException (DriverRuntimeException::class);
52-
52+
5353 // inserting a document with the same _id (baz)
5454 $ result = $ this ->col ->insertOne ([
5555 '_id ' => 'baz ' ,
5656 'bat ' => 'dog '
57- ]);
57+ ]);
5858 }
5959
6060 /**
@@ -162,8 +162,8 @@ public function testFindWithInvertedFilter()
162162 $ this ->col ->insertMany ([
163163 ['foo ' => 'bar ' ],
164164 ['foo ' => 'baz ' ]
165- ]);
166-
165+ ]);
166+
167167 $ result = $ this ->col ->count (['foo ' => ['$not ' => ['$in ' => ['bar ' , 'baz ' ]]]]);
168168 assertThat ($ result , equalTo (0 ));
169169
@@ -172,11 +172,15 @@ public function testFindWithInvertedFilter()
172172 assertThat (count ($ result ), equalTo (1 ));
173173 assertThat ($ result [0 ]['foo ' ], equalTo ('bar ' ));
174174
175- $ find = $ this ->col ->find (['foo ' => ['$not ' =>
176- ['$not ' =>
177- ['$eq ' => 'bar ' ]
175+ $ find = $ this ->col ->find ([
176+ 'foo ' => [
177+ '$not ' =>
178+ [
179+ '$not ' =>
180+ ['$eq ' => 'bar ' ]
181+ ]
178182 ]
179- ]] );
183+ ]);
180184 $ result = $ find ->toArray ();
181185 assertThat (count ($ result ), equalTo (1 ));
182186 assertThat ($ result [0 ]['foo ' ], equalTo ('bar ' ));
@@ -191,7 +195,7 @@ public function testFindWithInFilter()
191195 ['foo ' => ['bar ' , 'baz ' , 'bad ' ]],
192196 ['foo ' => ['baz ' , 'bad ' ]],
193197 ['foo ' => ['foobar ' , 'baroof ' ]]
194- ]);
198+ ]);
195199
196200 $ result = $ this ->col ->count (['foo ' => ['$in ' => ['barbar ' ]]]);
197201 assertThat ($ result , equalTo (0 ));
@@ -475,7 +479,7 @@ public function testUpdateIncrement()
475479 */
476480 public function testUpdatePush ()
477481 {
478- $ this ->col ->insertOne (
482+ $ this ->col ->insertOne (
479483 ['foo ' => 'foo ' , 'bar ' => []]
480484 );
481485
@@ -637,7 +641,7 @@ public function testFindWorksWithCallableOperators()
637641 }
638642 ]);
639643 $ result = iterator_to_array ($ result );
640-
644+
641645 assertThat (count ($ result ), equalTo (1 ));
642646 assertThat ($ result [0 ]['foo ' ], equalTo ('bar ' ));
643647 }
@@ -656,7 +660,7 @@ public function testFindWorksWithPhpUnitConstraints()
656660 'foo ' => equalTo ('bar ' )
657661 ]);
658662 $ result = iterator_to_array ($ result );
659-
663+
660664 assertThat (count ($ result ), equalTo (1 ));
661665 assertThat ($ result [0 ]['foo ' ], equalTo ('bar ' ));
662666 }
@@ -817,10 +821,12 @@ public function testManyByOrAndQuery()
817821 ['foo ' => 'baz ' , 'bar ' => 2 ],
818822 ]);
819823
820- $ result = $ this ->col ->find (['$or ' => [
821- ['$and ' => [['foo ' => 'foo ' ], ['bar ' => '3 ' ]]],
822- ['$and ' => [['foo ' => 'baz ' ], ['bar ' => '2 ' ]]],
823- ]]);
824+ $ result = $ this ->col ->find ([
825+ '$or ' => [
826+ ['$and ' => [['foo ' => 'foo ' ], ['bar ' => '3 ' ]]],
827+ ['$and ' => [['foo ' => 'baz ' ], ['bar ' => '2 ' ]]],
828+ ]
829+ ]);
824830
825831 assertThat ($ result , isInstanceOf (MockCursor::class));
826832 $ result = $ result ->toArray ();
@@ -840,10 +846,12 @@ public function testManyByAndOrQuery()
840846 ['foo ' => 'baz ' , 'bar ' => 2 ],
841847 ]);
842848
843- $ result = $ this ->col ->find (['$and ' => [
844- ['$or ' => [['foo ' => 1 ], ['foo ' => 'foo ' ]]],
845- ['$or ' => [['bar ' => 'foo ' ], ['bar ' => 3 ]]],
846- ]]);
849+ $ result = $ this ->col ->find ([
850+ '$and ' => [
851+ ['$or ' => [['foo ' => 1 ], ['foo ' => 'foo ' ]]],
852+ ['$or ' => [['bar ' => 'foo ' ], ['bar ' => 3 ]]],
853+ ]
854+ ]);
847855
848856 assertThat ($ result , isInstanceOf (MockCursor::class));
849857 $ result = $ result ->toArray ();
@@ -862,30 +870,38 @@ public function testManyByNorQuery()
862870 ['foo ' => 'baz ' , 'bar ' => 2 ],
863871 ]);
864872
865- $ result = $ this ->col ->count (['$nor ' => [
866- 'foo ' => ['$eq ' => 'foo ' ],
867- 'foo ' => ['$eq ' => 'bar ' ],
868- 'foo ' => ['$eq ' => 'baz ' ]
869- ]]);
873+ $ result = $ this ->col ->count ([
874+ '$nor ' => [
875+ 'foo ' => ['$eq ' => 'foo ' ],
876+ 'foo ' => ['$eq ' => 'bar ' ],
877+ 'foo ' => ['$eq ' => 'baz ' ]
878+ ]
879+ ]);
870880 assertThat ($ result , equalTo (0 ));
871881
872882 /* Finding ['foo' => 'foo', 'bar' => 3] */
873- $ result = $ this ->col ->count (['$nor ' => [
874- ['foo ' => ['$eq ' => 'bar ' ]],
875- ['foo ' => ['$eq ' => 'baz ' ]],
876- ['bar ' => ['$lt ' => 3 ]]
877- ]]);
883+ $ result = $ this ->col ->count ([
884+ '$nor ' => [
885+ ['foo ' => ['$eq ' => 'bar ' ]],
886+ ['foo ' => ['$eq ' => 'baz ' ]],
887+ ['bar ' => ['$lt ' => 3 ]]
888+ ]
889+ ]);
878890 assertThat ($ result , equalTo (1 ));
879891
880892 /* Finding ['foo' => 'bar', 'bar' => 1] */
881- $ result = $ this ->col ->count (['$nor ' => [
882- ['foo ' =>
883- ['$not ' => ['$eq ' => 'bar ' ]]
884- ],
885- ['bar ' =>
886- ['$not ' => ['$eq ' => 1 ]]
893+ $ result = $ this ->col ->count ([
894+ '$nor ' => [
895+ [
896+ 'foo ' =>
897+ ['$not ' => ['$eq ' => 'bar ' ]]
898+ ],
899+ [
900+ 'bar ' =>
901+ ['$not ' => ['$eq ' => 1 ]]
902+ ]
887903 ]
888- ]] );
904+ ]);
889905 assertThat ($ result , equalTo (1 ));
890906 }
891907
@@ -943,10 +959,12 @@ public function testManyOrGteAndLteQuery()
943959 ['foo ' => 'baz ' , 'bar ' => 2 ],
944960 ]);
945961
946- $ result = $ this ->col ->find (['$or ' => [
947- ['bar ' => ['$lte ' => 1 ]],
948- ['bar ' => ['$gte ' => 3 ]]
949- ]]);
962+ $ result = $ this ->col ->find ([
963+ '$or ' => [
964+ ['bar ' => ['$lte ' => 1 ]],
965+ ['bar ' => ['$gte ' => 3 ]]
966+ ]
967+ ]);
950968
951969 assertThat ($ result , isInstanceOf (MockCursor::class));
952970 $ result = $ result ->toArray ();
@@ -1118,4 +1136,19 @@ public function testFindOneAndUpdateWithReturnDocumentAfter()
11181136 assertThat ($ documentAfterUpdate ['bar ' ], equalTo (23 ));
11191137 }
11201138
1139+ public function testSetMultiDimensionalArray ()
1140+ {
1141+ $ col = new MockCollection ('foo ' );
1142+ $ insertOneResult = $ col ->insertOne (['foo ' => ['foo ' => ['bar ' => "test " ]], 'bar ' => 42 ]);
1143+
1144+ $ col ->updateOne (
1145+ ['_id ' => $ insertOneResult ->getInsertedId ()],
1146+ [
1147+ '$set ' => ["foo.foo.bar " => "azerty " ]
1148+ ]
1149+ );
1150+
1151+ $ documentAfterUpdate = $ col ->findOne (['_id ' => $ insertOneResult ->getInsertedId ()]);
1152+ assertThat ($ documentAfterUpdate ['foo ' ]['foo ' ]['bar ' ], equalTo ("azerty " ), $ documentAfterUpdate ['foo ' ]['foo ' ]['bar ' ]);
1153+ }
11211154}
0 commit comments