From 5a955c633c1ac314ccff3fe5a719ae730105c13a Mon Sep 17 00:00:00 2001 From: brettp Date: Sun, 13 Feb 2011 23:53:30 +0000 Subject: Deprecated ElggEntity->clearMetadata() by ElggEntity->deleteMetadata(). Disabling entities now disables their annotations and metadata. Enabling entities enables annotations and metadata. Fixes #1115. git-svn-id: http://code.elgg.org/elgg/trunk@8213 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/tests/objects/entities.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'engine/tests') diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 67dd02596..824b47a8a 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -186,19 +186,42 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // ensure enabled $this->assertTrue($this->entity->isEnabled()); - // false on disable + // false on disable because it's not saved yet. $this->assertFalse($this->entity->disable()); // save and disable $this->save_entity(); + + // add annotations and metadata to check if they're disabled. + $annotation_id = create_annotation($this->entity->guid, 'test_annotation_' . rand(), 'test_value_' . rand()); + $metadata_id = create_metadata($this->entity->guid, 'test_metadata_' . rand(), 'test_value_' . rand()); + $this->assertTrue($this->entity->disable()); // ensure disabled by comparing directly with database $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'"); $this->assertIdentical($entity->enabled, 'no'); + $annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '$annotation_id'"); + $this->assertIdentical($annotation->enabled, 'no'); + + $metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '$metadata_id'"); + $this->assertIdentical($metadata->enabled, 'no'); + // re-enable for deletion to work $this->assertTrue($this->entity->enable()); + + // check enabled + // check annotations and metadata enabled. + $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'"); + $this->assertIdentical($entity->enabled, 'yes'); + + $annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '$annotation_id'"); + $this->assertIdentical($annotation->enabled, 'yes'); + + $metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '$metadata_id'"); + $this->assertIdentical($metadata->enabled, 'yes'); + $this->assertTrue($this->entity->delete()); } -- cgit v1.2.3