/** * Test for issue #15230: php fatal error in fetch reverse_related_object * * This tests checks that eZContentFunctionCollection::fetchReverseRelatedObjects * and eZContentFunctionCollection::fetchRelatedObjectsCount won't throw a * fatal error if provided with a non-existing object ID * * @link http://issues.ez.no/15230 */ public function testIssue15230() { $nonExistingArticleID = 100000000; $this->assertFalse(eZContentFunctionCollection::fetchRelatedObjects($nonExistingArticleID, false, true, false, false), "eZContentFunctionCollection::fetchRelatedObjects({$nonExistingArticleID}) should have returned false"); $this->assertFalse(eZContentFunctionCollection::fetchRelatedObjectsCount($nonExistingArticleID, false, true, false, false), "eZContentFunctionCollection::fetchRelatedObjectsCount({$nonExistingArticleID}) should have returned false"); $this->assertFalse(eZContentFunctionCollection::fetchReverseRelatedObjects($nonExistingArticleID, false, true, false, false, false), "eZContentFunctionCollection::fetchReverseRelatedObjects({$nonExistingArticleID}) should have returned false"); $this->assertFalse(eZContentFunctionCollection::fetchReverseRelatedObjectsCount($nonExistingArticleID, false, true, false, false, false), "eZContentFunctionCollection::fetchReverseRelatedObjectsCount({$nonExistingArticleID}) should have returned false"); }
/** * Unit test for eZContentFunctionCollection::fetchReverseRelatedObjectsCount */ public function testFetchReverseRelatedObjectsCount() { $object1 = new ezpObject('article', 2); $object1->title = __FUNCTION__ . ' A'; $object1->publish(); $object2 = new ezpObject('article', 2); $object2->title = __FUNCTION__ . ' B'; $object2->addContentObjectRelation($object1->attribute('id')); $object2->publish(); $ret = eZContentFunctionCollection::fetchReverseRelatedObjectsCount($object1->attribute('id'), false, true, false); $this->assertInternalType('array', $ret); $this->assertArrayHasKey('result', $ret); $this->assertEquals(1, $ret['result']); }