1111namespace xPDO \Test \Om ;
1212
1313use xPDO \Om \xPDOObject ;
14+ use xPDO \Test \Sample \Person ;
1415use xPDO \TestCase ;
1516use xPDO \xPDO ;
1617
@@ -327,6 +328,13 @@ public function testCascadeSave()
327328 $ person ->remove ();
328329 }
329330
331+ public function testGetObjectDoesNotReturnUnexpectedResults ()
332+ {
333+ $ person = $ this ->xpdo ->getObject ('xPDO \\Test \\Sample \\Person ' , 'test ' );
334+
335+ $ this ->assertNull ($ person , 'getObject returned an instance from an invalid key ' );
336+ }
337+
330338 /**
331339 * Test getting an object by the primary key.
332340 *
@@ -393,6 +401,13 @@ public function testGetObjectGraphsByPK()
393401 $ this ->assertTrue ($ phone instanceof \xPDO \Test \Sample \Phone, "Error retrieving related Phone object via getObjectGraph " );
394402 }
395403
404+ public function testGetObjectGraphDoesNotReturnUnexpectedResults ()
405+ {
406+ $ person = $ this ->xpdo ->getObjectGraph ('xPDO \\Test \\Sample \\Person ' , '{"PersonPhone":{"Phone":{}}} ' , 'test ' );
407+
408+ $ this ->assertNull ($ person , 'getObjectGraph returned unexpected result from invalid key ' );
409+ }
410+
396411 /**
397412 * Test getObjectGraph by PK with JSON graph
398413 */
@@ -421,6 +436,13 @@ public function testGetObjectGraphsJSONByPK()
421436 $ this ->assertTrue ($ phone instanceof \xPDO \Test \Sample \Phone, "Error retrieving related Phone object via getObjectGraph, JSON graph " );
422437 }
423438
439+ public function testGetCollectionDoesNotReturnUnexpectedResults ()
440+ {
441+ $ person = $ this ->xpdo ->getCollection ('xPDO \\Test \\Sample \\Person ' , 'test ' );
442+
443+ $ this ->assertEmpty ($ person , 'getCollection returned data from an invalid where clause ' );
444+ }
445+
424446 /**
425447 * Test xPDO::getCollection
426448 */
@@ -436,6 +458,13 @@ public function testGetCollection()
436458 $ this ->assertTrue (count ($ people ) == 2 , "Error retrieving all objects. " );
437459 }
438460
461+ public function testGetCollectionGraphDoesNotReturnUnexpectedResults ()
462+ {
463+ $ person = $ this ->xpdo ->getCollectionGraph ('xPDO \\Test \\Sample \\Person ' , array ('PersonPhone ' => array ('Phone ' => array ())), 'test ' );
464+
465+ $ this ->assertEmpty ($ person , 'getCollectionGraph returned data from an invalid where clause ' );
466+ }
467+
439468 /**
440469 * Test xPDO::getCollectionGraph
441470 */
0 commit comments