@@ -73,10 +73,8 @@ public function testConstructWithWrongType(): void
73
73
}
74
74
75
75
/** @dataProvider provideTestDocumentWithNativeArrays */
76
- public function testConstructWithArrayUsesLiteralValues ($ value ): void
76
+ public function testConstructWithArrayUsesLiteralValues ($ document ): void
77
77
{
78
- $ document = new LazyBSONDocument ($ value );
79
-
80
78
$ this ->assertInstanceOf (stdClass::class, $ document ->document );
81
79
$ this ->assertIsArray ($ document ->hash );
82
80
$ this ->assertIsArray ($ document ->array );
@@ -143,6 +141,15 @@ public function testOffsetGetForMissingOffset(LazyBSONDocument $document): void
143
141
$ document ['bar ' ];
144
142
}
145
143
144
+ public function testOffsetGetWithInvalidOffset (): void
145
+ {
146
+ $ document = new LazyBSONDocument (['foo ' => 'bar ' ]);
147
+
148
+ $ this ->expectWarning ();
149
+ $ this ->expectWarningMessage ('Undefined offset: 1 ' );
150
+ $ document [1 ];
151
+ }
152
+
146
153
/** @dataProvider provideTestDocument */
147
154
public function testGetDocument (LazyBSONDocument $ document ): void
148
155
{
@@ -171,6 +178,13 @@ public function testOffsetExists(LazyBSONDocument $document): void
171
178
$ this ->assertFalse (isset ($ document ['bar ' ]));
172
179
}
173
180
181
+ public function testOffsetExistsWithInvalidOffset (): void
182
+ {
183
+ $ document = new LazyBSONDocument (['foo ' => 'bar ' ]);
184
+
185
+ $ this ->assertFalse (isset ($ document [1 ]));
186
+ }
187
+
174
188
/** @dataProvider provideTestDocument */
175
189
public function testPropertySet (LazyBSONDocument $ document ): void
176
190
{
@@ -195,6 +209,15 @@ public function testOffsetSet(LazyBSONDocument $document): void
195
209
$ this ->assertSame ('baz ' , $ document ['foo ' ]);
196
210
}
197
211
212
+ public function testOffsetSetWithInvalidOffset (): void
213
+ {
214
+ $ document = new LazyBSONDocument (['foo ' => 'bar ' ]);
215
+
216
+ $ this ->expectWarning ();
217
+ $ this ->expectWarningMessage ('Unsupported offset: 1 ' );
218
+ $ document [1 ] = 'foo ' ;
219
+ }
220
+
198
221
/** @dataProvider provideTestDocument */
199
222
public function testPropertyUnset (LazyBSONDocument $ document ): void
200
223
{
@@ -229,6 +252,15 @@ public function testOffsetUnset(LazyBSONDocument $document): void
229
252
$ this ->assertFalse (isset ($ document ['document ' ]));
230
253
}
231
254
255
+ public function testOffsetUnsetWithInvalidOffset (): void
256
+ {
257
+ $ document = new LazyBSONDocument (['foo ' => 'bar ' ]);
258
+
259
+ $ this ->expectWarning ();
260
+ $ this ->expectWarningMessage ('Undefined offset: 1 ' );
261
+ unset($ document [1 ]);
262
+ }
263
+
232
264
/** @dataProvider provideTestDocument */
233
265
public function testIterator (LazyBSONDocument $ document ): void
234
266
{
0 commit comments