From 8f0161a9d382b5610326576a6f572d0beb8c3e03 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 10 Mar 2010 22:03:58 +0000 Subject: Added elgg_instanceof(). git-svn-id: http://code.elgg.org/elgg/trunk@5353 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/tests/api/helpers.php | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 engine/tests/api/helpers.php (limited to 'engine/tests') diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php new file mode 100644 index 000000000..a2152a0ef --- /dev/null +++ b/engine/tests/api/helpers.php @@ -0,0 +1,67 @@ +swallowErrors(); + } + + /** + * Called after each test object. + */ + public function __destruct() { + // all __destruct() code should go above here + parent::__destruct(); + } + + /** + * Test elgg_instanceof() + * @return unknown_type + */ + public function testElggInstanceOf() { + $entity = new ElggObject(); + $entity->subtype = 'test_subtype'; + $entity->save(); + + $this->assertTrue(elgg_instanceof($entity)); + $this->assertTrue(elgg_instanceof($entity, 'object')); + $this->assertTrue(elgg_instanceof($entity, 'object', 'test_subtype')); + + $this->assertFalse(elgg_instanceof($entity, 'object', 'invalid_subtype')); + $this->assertFalse(elgg_instanceof($entity, 'user', 'test_subtype')); + + $entity->delete(); + + $bad_entity = FALSE; + $this->assertFalse(elgg_instanceof($bad_entity)); + $this->assertFalse(elgg_instanceof($bad_entity, 'object')); + $this->assertFalse(elgg_instanceof($bad_entity, 'object', 'test_subtype')); + + } +} -- cgit v1.2.3