@@ -237,6 +237,37 @@ public function testRegisterAfterEval($registerCallback)
237
237
$ registerCallback ($ el );
238
238
}
239
239
240
+ public function testBadProperty ()
241
+ {
242
+ $ this ->expectException (\RuntimeException::class);
243
+ $ this ->expectExceptionMessageMatches ('/Unable to get property "\w+" of object "\w+"./ ' );
244
+ $ el = new ExpressionLanguage ();
245
+ $ el ->evaluate ('foo.bar ' , ['foo ' => new \stdClass ()]);
246
+ }
247
+
248
+ public function testBadPropertyNullSafe ()
249
+ {
250
+ $ this ->expectException (\RuntimeException::class);
251
+ $ this ->expectExceptionMessageMatches ('/Unable to get property "\w+" of object "\w+"./ ' );
252
+ $ el = new ExpressionLanguage ();
253
+ $ el ->evaluate ('foo?.bar ' , ['foo ' => new \stdClass ()]);
254
+ }
255
+
256
+ public function testBadObjectGetProperty ()
257
+ {
258
+ $ this ->expectException (\RuntimeException::class);
259
+ $ this ->expectExceptionMessageMatches ('/Unable to get property "\w+" of non-object "\w+"./ ' );
260
+ $ el = new ExpressionLanguage ();
261
+ $ el ->evaluate ('foo.bar ' , ['foo ' => null ]);
262
+ }
263
+
264
+ public function testBadObjectGetPropertyNullSafe ()
265
+ {
266
+ $ el = new ExpressionLanguage ();
267
+ $ result = $ el ->evaluate ('foo?.bar ' , ['foo ' => null ]);
268
+ $ this ->assertNull ($ result );
269
+ }
270
+
240
271
public function testCallBadCallable ()
241
272
{
242
273
$ this ->expectException (\RuntimeException::class);
@@ -245,10 +276,24 @@ public function testCallBadCallable()
245
276
$ el ->evaluate ('foo.myfunction() ' , ['foo ' => new \stdClass ()]);
246
277
}
247
278
248
- public function testCallBadCallableWithNullSafe ()
279
+ public function testCallBadCallableNullSafe ()
249
280
{
250
281
$ el = new ExpressionLanguage ();
282
+ $ this ->expectExceptionMessageMatches ('/Unable to call method "\w+" of object "\w+"./ ' );
251
283
$ result = $ el ->evaluate ('foo?.myfunction() ' , ['foo ' => new \stdClass ()]);
284
+ }
285
+
286
+ public function testBadObjectCallCallable ()
287
+ {
288
+ $ el = new ExpressionLanguage ();
289
+ $ this ->expectExceptionMessageMatches ('/Unable to call method "\w+" of non-object "\w+"./ ' );
290
+ $ result = $ el ->evaluate ('foo.myfunction() ' , ['foo ' => null ]);
291
+ }
292
+
293
+ public function testBadObjectCallCallableNullSafe ()
294
+ {
295
+ $ el = new ExpressionLanguage ();
296
+ $ result = $ el ->evaluate ('foo?.myfunction() ' , ['foo ' => null ]);
252
297
$ this ->assertNull ($ result );
253
298
}
254
299
0 commit comments