]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3942 fixed all the warnings and notices in the unit tests
authorCash Costello <cash.costello@gmail.com>
Sun, 9 Oct 2011 01:52:34 +0000 (21:52 -0400)
committerCash Costello <cash.costello@gmail.com>
Sun, 9 Oct 2011 01:52:34 +0000 (21:52 -0400)
engine/classes/ElggAnnotation.php
engine/lib/access.php
engine/lib/annotations.php
engine/tests/api/access_collections.php
engine/tests/api/helpers.php
engine/tests/api/metadata.php
engine/tests/objects/entities.php
engine/tests/objects/users.php
engine/tests/regression/trac_bugs.php
mod/groups/start.php

index 78d29ee7f7efb22dfec7ebde2b32aa5a75abb1d7..511b5151fb158f3f230dca51aa472c4d35f39072 100644 (file)
@@ -78,7 +78,7 @@ class ElggAnnotation extends ElggExtender {
         * @return bool
         */
        function delete() {
-               remove_from_river_by_annotation($this->id);
+               elgg_delete_river(array('annotation_id' => $this->id));
                return elgg_delete_metastring_based_object_by_id($this->id, 'annotations');
        }
 
index e8cec50d0fd8c167f7f9b4b5f6a3bb3b6c12f2e1..ae64f832a16f86627f7e1ab21232a5d14f2ad606 100644 (file)
@@ -460,7 +460,7 @@ function can_edit_access_collection($collection_id, $user_guid = null) {
        if ($user_guid) {
                $user = get_entity((int) $user_guid);
        } else {
-               $user = get_loggedin_user();
+               $user = elgg_get_logged_in_user_entity();
        }
 
        $collection = get_access_collection($collection_id);
index 814c3555b8b3fc881f85b58b6a074143757c89af..c227c5516c5b9d3c902886d13074c444eccb47a0 100644 (file)
@@ -56,14 +56,14 @@ function elgg_delete_annotation_by_id($id) {
  * @param int    $entity_guid Entity Guid
  * @param string $name        Name of annotation
  * @param string $value       Value of annotation
- * @param string $value_type  Type of value
- * @param int    $owner_guid  Owner of annotation
+ * @param string $value_type  Type of value (default is auto detection)
+ * @param int    $owner_guid  Owner of annotation (default is logged in user)
  * @param int    $access_id   Access level of annotation
  *
  * @return int|bool id on success or false on failure
  */
-function create_annotation($entity_guid, $name, $value, $value_type,
-$owner_guid, $access_id = ACCESS_PRIVATE) {
+function create_annotation($entity_guid, $name, $value, $value_type = '',
+$owner_guid = 0, $access_id = ACCESS_PRIVATE) {
        global $CONFIG;
 
        $result = false;
index 1e61c45bb060568781c1920677cb720a92980d44..bc5408546da99917c3baa4c36f793f7b56e06249 100644 (file)
@@ -194,7 +194,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
                        return $value;
                }
 
-               register_plugin_hook('access:collections:write', 'all', 'test_acl_access_hook');
+               elgg_register_plugin_hook_handler('access:collections:write', 'all', 'test_acl_access_hook');
 
                // enable security since we usually run as admin
                $ia = elgg_set_ignore_access(false);
@@ -202,14 +202,14 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
                $this->assertTrue($result);
                $ia = elgg_set_ignore_access($ia);
 
-               unregister_plugin_hook('access:collections:write', 'all', 'test_acl_access_hook');
+               elgg_unregister_plugin_hook_handler('access:collections:write', 'all', 'test_acl_access_hook');
        }
 
        // groups interface
        // only runs if the groups plugin is enabled because implementation is split between
        // core and the plugin.
        public function testCreateDeleteGroupACL() {
-               if (!is_plugin_enabled('groups')) {
+               if (!elgg_is_active_plugin('groups')) {
                        return;
                }
                
@@ -231,7 +231,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
        }
 
        public function testJoinLeaveGroupACL() {
-               if (!is_plugin_enabled('groups')) {
+               if (!elgg_is_active_plugin('groups')) {
                        return;
                }
 
index 36d680d5402b72478664858ce627e05e0d120b6a..3f41400c851f0bf2b61991489ab788115c09efe7 100644 (file)
@@ -166,7 +166,9 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
                $this->assertFalse(isset($CONFIG->externals_map['js']['id1']));
                
                foreach ($elements as $element) {
-                       $this->assertFalse($element->name == 'id1');
+                       if (isset($element->name)) {
+                               $this->assertFalse($element->name == 'id1');
+                       }
                }
 
                $result = elgg_unregister_js('id1');
@@ -180,7 +182,9 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
 
                $this->assertFalse(isset($CONFIG->externals_map['js']['id2']));
                foreach ($elements as $element) {
-                       $this->assertFalse($element->name == 'id2');
+                       if (isset($element->name)) {
+                               $this->assertFalse($element->name == 'id2');
+                       }
                }
 
                $this->assertTrue(isset($CONFIG->externals_map['js']['id3']));
index d9113b68a1503369f4f5e7118a6bc65a697f0f8c..208024e658add187ddaabfc05b92cd2256bc897e 100644 (file)
@@ -75,13 +75,6 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest {
 
                $this->assertIdentical($case_true, $case_false);
 
-               // check deprecated get_entities_from_metadata() function
-               $deprecated = get_entities_from_metadata('metaUnitTest', 'tested', '', '', 0, 10, 0, '', 0, FALSE, TRUE);
-               $this->assertIdentical($deprecated, $case_true);
-
-               // check entity list
-               //$this->dump(list_entities_from_metadata('metaUnitTest', 'Tested', '', '', 0, 10, TRUE, TRUE, TRUE, FALSE));
-
                // clean up
                $this->delete_metastrings();
                $this->object->delete();
index c04bc60fff10468fa4d84fc7a9a4e4d0fc9a9c57..c0a7b96b396e35b0f2b625c402d2f93ca15478eb 100644 (file)
@@ -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
index ba93c24392f9eddc23bf86f4ffaca0354ece1aed..d1533c3d2921e05f445d3629b19cfd38a92a53a7 100644 (file)
@@ -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;
 
index 23d6d1dc680f65ec9397e8d6f8aaf654ceda50ee..2bfc37558559ad530031011f3163d5bb97578b68 100644 (file)
@@ -146,9 +146,9 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest {
                        }
                }
                
-               register_plugin_hook('container_permissions_check', 'all', 'can_write_to_container_test_hook');
+               elgg_register_plugin_hook_handler('container_permissions_check', 'all', 'can_write_to_container_test_hook');
                $this->assertTrue(can_write_to_container($user->guid, $object->guid));
-               unregister_plugin_hook('container_permissions_check', 'all', 'can_write_to_container_test_hook');
+               elgg_unregister_plugin_hook_handler('container_permissions_check', 'all', 'can_write_to_container_test_hook');
 
                $this->assertFalse(can_write_to_container($user->guid, $group->guid));
                $group->join($user);
index 0425bdea6d9492085b5a80ff66e4aec55f064610..1b5b03ce7ccb04a3e46c7d7d343c36d6b06c9422 100644 (file)
@@ -562,8 +562,10 @@ function groups_user_join_event_listener($event, $object_type, $object) {
  * Make sure users are added to the access collection
  */
 function groups_access_collection_override($hook, $entity_type, $returnvalue, $params) {
-       if (elgg_instanceof(get_entity($params['collection']->owner_guid), 'group')) {
-               return true;
+       if (isset($params['collection'])) {
+               if (elgg_instanceof(get_entity($params['collection']->owner_guid), 'group')) {
+                       return true;
+               }
        }
 }