From ba4bbf484d33fe24332ff63ac3b063f346a2a74c Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 8 Oct 2011 21:52:34 -0400 Subject: Fixes #3942 fixed all the warnings and notices in the unit tests --- engine/tests/objects/entities.php | 12 ++++++------ engine/tests/objects/users.php | 23 ----------------------- 2 files changed, 6 insertions(+), 29 deletions(-) (limited to 'engine/tests/objects') diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index c04bc60ff..c0a7b96b3 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -125,7 +125,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertIdentical(FALSE, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'site', 'subtype' => 'fail'))); // clear annotation - $this->assertTrue($this->entity->clearAnnotations()); + $this->assertTrue($this->entity->deleteAnnotations()); $this->assertEqual($this->entity->countAnnotations('non_existent'), 0); $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID()))); @@ -226,8 +226,8 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { } public function testElggEntityMetadata() { - // let's delte a non-existent metadata - $this->assertFalse($this->entity->clearMetaData('important')); + // let's delete a non-existent metadata + $this->assertFalse($this->entity->deleteMetadata('important')); // let's add the meatadata $this->assertTrue($this->entity->important = 'indeed!'); @@ -236,16 +236,16 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // test deleting incorrectly // @link http://trac.elgg.org/ticket/2273 - $this->assertFalse($this->entity->clearMetaData('impotent')); + $this->assertFalse($this->entity->deleteMetadata('impotent')); $this->assertEqual($this->entity->important, 'indeed!'); // get rid of one metadata $this->assertEqual($this->entity->important, 'indeed!'); - $this->assertTrue($this->entity->clearMetaData('important')); + $this->assertTrue($this->entity->deleteMetadata('important')); $this->assertEqual($this->entity->important, ''); // get rid of all metadata - $this->assertTrue($this->entity->clearMetaData()); + $this->assertTrue($this->entity->deleteMetadata()); $this->assertEqual($this->entity->less_important, ''); // clean up database diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index ba93c2439..d1533c3d2 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -220,29 +220,6 @@ class ElggCoreUserTest extends ElggCoreUnitTest { $this->user->delete(); } - // remove in 1.9 - public function testElggUserIsAdminLegacy() { - $this->user->save(); - $this->user->makeAdmin(); - - $this->assertTrue($this->user->admin); - $this->assertTrue($this->user->siteadmin); - - $this->user->removeAdmin(); - $this->user->delete(); - } - - public function testElggUserIsNotAdminLegacy() { - $this->user->save(); - $this->user->removeAdmin(); - - $this->assertFalse($this->user->admin); - $this->assertFalse($this->user->siteadmin); - - $this->user->removeAdmin(); - $this->user->delete(); - } - protected function fetchUser($guid) { global $CONFIG; -- cgit v1.2.3 From 99a8c831f9487f2c99dd6467eb8dc48ea2d54883 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 8 Oct 2011 22:10:49 -0400 Subject: Fixes #3897 fixed source of infinite regression loop in delete_entity() --- engine/lib/entities.php | 6 +++++- engine/tests/objects/sites.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'engine/tests/objects') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 78fa915dd..f1352ba8d 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1507,7 +1507,11 @@ function delete_entity($guid, $recursive = true) { or site_guid=$guid", 'entity_row_to_elggstar'); if ($sub_entities) { foreach ($sub_entities as $e) { - $e->delete(true); + // check for equality so that an entity that is its own + // owner or container does not cause infinite loop + if ($e->guid != $guid) { + $e->delete(true); + } } } diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index d0d61dcab..e5acbb3f9 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -18,7 +18,7 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { * Called before each test method. */ public function setUp() { - $this->site = new ElggSiteTest; + $this->site = new ElggSiteTest(); } /** -- cgit v1.2.3 From b2cbd24e9af7aab7130c3cbf732043e3aa6477c3 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 8 Oct 2011 22:35:01 -0400 Subject: Fixes #3946 deleting the temporary entities created in entity unit tests --- engine/tests/objects/entities.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'engine/tests/objects') diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index c0a7b96b3..49b1764bc 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -278,6 +278,10 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->entity->$name = $md; $this->assertEqual($md, $this->entity->$name); + + if ($save) { + $this->assertTrue($this->entity->delete()); + } } } @@ -292,6 +296,10 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->entity->$name = $md; $this->assertEqual($md[0], $this->entity->$name); + + if ($save) { + $this->assertTrue($this->entity->delete()); + } } } @@ -307,6 +315,10 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->entity->setMetaData($name, 'test2', '', true); $this->assertEqual(array('test', 'test2'), $this->entity->$name); + + if ($save) { + $this->assertTrue($this->entity->delete()); + } } } @@ -322,6 +334,10 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->entity->setMetaData($name, array('test2'), '', true); $this->assertEqual(array('test', 'test2'), $this->entity->$name); + + if ($save) { + $this->assertTrue($this->entity->delete()); + } } } @@ -338,11 +354,14 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->entity->setMetaData($name, $md2, '', true); $this->assertEqual(array_merge($md, $md2), $this->entity->$name); + + if ($save) { + $this->assertTrue($this->entity->delete()); + } } } - protected function save_entity($type='site') - { + protected function save_entity($type='site') { $this->entity->type = $type; $this->assertNotEqual($this->entity->save(), 0); } -- cgit v1.2.3 From 048cc79f50fdd909a6ad38426db3991902a83048 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 9 Oct 2011 08:35:42 -0400 Subject: Fixes #3948 cleaning up stuff left behind by unit tests --- engine/tests/api/access_collections.php | 2 ++ engine/tests/api/entity_getter_functions.php | 2 +- engine/tests/api/helpers.php | 2 ++ engine/tests/api/metadata.php | 2 +- engine/tests/objects/entities.php | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engine/tests/objects') diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php index bc5408546..0c37fa779 100644 --- a/engine/tests/api/access_collections.php +++ b/engine/tests/api/access_collections.php @@ -203,6 +203,8 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest { $ia = elgg_set_ignore_access($ia); elgg_unregister_plugin_hook_handler('access:collections:write', 'all', 'test_acl_access_hook'); + + delete_access_collection($acl_id); } // groups interface diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index 59b48999c..e7906d3c8 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -855,7 +855,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { public function testElggApiGettersEntityNoSubtype() { // create an entity we can later delete. - // order by time created and limit by 1 should == this entity. + // order by guid and limit by 1 should == this entity. $e = new ElggObject(); $e->save(); diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php index 3f41400c8..439d5aa46 100644 --- a/engine/tests/api/helpers.php +++ b/engine/tests/api/helpers.php @@ -63,6 +63,8 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $this->assertFalse(elgg_instanceof($bad_entity)); $this->assertFalse(elgg_instanceof($bad_entity, 'object')); $this->assertFalse(elgg_instanceof($bad_entity, 'object', 'test_subtype')); + + remove_subtype('object', 'test_subtype'); } /** diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php index 208024e65..7897b8d47 100644 --- a/engine/tests/api/metadata.php +++ b/engine/tests/api/metadata.php @@ -76,8 +76,8 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { $this->assertIdentical($case_true, $case_false); // clean up - $this->delete_metastrings(); $this->object->delete(); + $this->delete_metastrings(); } public function testElggGetMetadataCount() { diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 49b1764bc..c13b4c731 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -134,6 +134,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // clean up $this->assertTrue($this->entity->delete()); + remove_subtype('site', 'testing'); } public function testElggEntityCache() { -- cgit v1.2.3