From 4befaea34c2617e0ae8b246bb42f582af6f100e4 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 4 Jan 2012 20:13:05 -0500 Subject: added a unit test for recursive enabling/disabling --- engine/tests/objects/entities.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'engine/tests') diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 1772f7c1a..a4dc7946c 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -226,6 +226,39 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertTrue($this->entity->delete()); } + public function testElggEntityRecursiveDisableAndEnable() { + global $CONFIG; + + $this->save_entity(); + $obj1 = new ElggObject(); + $obj1->container_guid = $this->entity->getGUID(); + $obj1->save(); + $obj2 = new ElggObject(); + $obj2->container_guid = $this->entity->getGUID(); + $obj2->save(); + + // disable $obj2 before disabling the container + $this->assertTrue($obj2->disable()); + + // disable entities container by $this->entity + $this->assertTrue($this->entity->disable()); + $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj1->guid}'"); + $this->assertIdentical($entity->enabled, 'no'); + + // enable entities that were disabled with the container (but not $obj2) + $this->assertTrue($this->entity->enable()); + $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj1->guid}'"); + $this->assertIdentical($entity->enabled, 'yes'); + $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj2->guid}'"); + $this->assertIdentical($entity->enabled, 'no'); + + // cleanup + $this->assertTrue($obj2->enable()); + $this->assertTrue($obj2->delete()); + $this->assertTrue($obj1->delete()); + $this->assertTrue($this->entity->delete()); + } + public function testElggEntityMetadata() { // let's delete a non-existent metadata $this->assertFalse($this->entity->deleteMetadata('important')); -- cgit v1.2.3