diff options
author | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-08 22:04:50 +0000 |
---|---|---|
committer | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-08 22:04:50 +0000 |
commit | 4bad66f81ae1c6798af56121ffba1045a36ee034 (patch) | |
tree | b11acb9bff457d898d312abcbac0cbd036ad6b0d /engine/tests | |
parent | b291acfd03be87038a1804d454a2f0f84412e17f (diff) | |
download | elgg-4bad66f81ae1c6798af56121ffba1045a36ee034.tar.gz elgg-4bad66f81ae1c6798af56121ffba1045a36ee034.tar.bz2 |
Adding unit test for ElggEntity annotations.
git-svn-id: http://code.elgg.org/elgg/trunk@3518 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/tests')
-rw-r--r-- | engine/tests/objects/entities.php | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index f13252871..be9c11a6f 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -96,6 +96,26 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $metadata = $this->entity->expose_metadata(); $this->assertIdentical($metadata['non_existent'], 'testing'); } + + public function testElggEnityGetAndSetAnnotations() { + $this->assertFalse(array_key_exists('non_existent', $this->entity->expose_annotations())); + $this->assertFalse($this->entity->getAnnotations('non_existent')); + + // set and check temp annotation + $this->assertTrue($this->entity->annotate('non_existent', 'testing')); + $this->assertIdentical($this->entity->getAnnotations('non_existent'), 'testing'); + $this->assertTrue(array_key_exists('non_existent', $this->entity->expose_annotations())); + + // save entity and check for annotation + $this->save_entity(); + $this->assertFalse(array_key_exists('non_existent', $this->entity->expose_annotations())); + $annotations = $this->entity->getAnnotations('non_existent'); + $this->assertIsA($annotations[0], 'ElggAnnotation'); + $this->assertIdentical($annotations[0]->name, 'non_existent'); + + // clean up + $this->assertTrue($this->entity->delete()); + } public function testElggEntityCache() { global $ENTITY_CACHE; @@ -156,8 +176,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertFalse($this->entity->disable()); // save and disable - $this->entity->type = 'site'; - $this->assertNotEqual($this->entity->save(), 0); + $this->save_entity(); $this->assertTrue($this->entity->disable()); // ensure disabled by comparing directly with database @@ -168,6 +187,12 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertTrue($this->entity->enable()); $this->assertTrue($this->entity->delete()); } + + protected function save_entity($type='site') + { + $this->entity->type = $type; + $this->assertNotEqual($this->entity->save(), 0); + } } // ElggEntity is an abstract class with no abstact methods. @@ -176,10 +201,6 @@ class ElggEntityTest extends ElggEntity { $this->initialise_attributes(); } - public function load($guid) { - return parent::load($guid); - } - public function expose_attributes() { return $this->attributes; } @@ -187,4 +208,8 @@ class ElggEntityTest extends ElggEntity { public function expose_metadata() { return $this->temp_metadata; } + + public function expose_annotations() { + return $this->temp_annotations; + } } |