aboutsummaryrefslogtreecommitdiff
path: root/engine/tests
diff options
context:
space:
mode:
Diffstat (limited to 'engine/tests')
-rw-r--r--engine/tests/api/access_collections.php10
-rw-r--r--engine/tests/api/entity_getter_functions.php2
-rw-r--r--engine/tests/api/helpers.php16
-rw-r--r--engine/tests/api/metadata.php9
-rw-r--r--engine/tests/api/plugins.php5
-rw-r--r--engine/tests/objects/entities.php36
-rw-r--r--engine/tests/objects/sites.php2
-rw-r--r--engine/tests/objects/users.php23
-rw-r--r--engine/tests/regression/trac_bugs.php4
-rw-r--r--engine/tests/test_files/plugin_18/manifest.xml1
-rw-r--r--engine/tests/ui/submenu.php103
11 files changed, 53 insertions, 158 deletions
diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php
index 1e61c45bb..0c37fa779 100644
--- a/engine/tests/api/access_collections.php
+++ b/engine/tests/api/access_collections.php
@@ -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,16 @@ 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');
+
+ delete_access_collection($acl_id);
}
// 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 +233,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
}
public function testJoinLeaveGroupACL() {
- if (!is_plugin_enabled('groups')) {
+ if (!elgg_is_active_plugin('groups')) {
return;
}
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 36d680d54..f48f91faf 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');
}
/**
@@ -72,7 +74,13 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$conversions = array(
'http://example.com' => 'http://example.com',
'https://example.com' => 'https://example.com',
+ 'http://example-time.com' => 'http://example-time.com',
+
'//example.com' => '//example.com',
+ 'ftp://example.com/file' => 'ftp://example.com/file',
+ 'mailto:brett@elgg.org' => 'mailto:brett@elgg.org',
+ 'javascript:alert("test")' => 'javascript:alert("test")',
+ 'app://endpoint' => 'app://endpoint',
'example.com' => 'http://example.com',
'example.com/subpage' => 'http://example.com/subpage',
@@ -166,7 +174,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 +190,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']));
diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php
index d9113b68a..7897b8d47 100644
--- a/engine/tests/api/metadata.php
+++ b/engine/tests/api/metadata.php
@@ -75,16 +75,9 @@ 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();
+ $this->delete_metastrings();
}
public function testElggGetMetadataCount() {
diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php
index 72092b688..8f5f5dd1e 100644
--- a/engine/tests/api/plugins.php
+++ b/engine/tests/api/plugins.php
@@ -105,7 +105,6 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => 1.0),
),
- 'admin_interface' => 'simple',
'activate_on_install' => true
);
@@ -265,10 +264,6 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
$this->assertEqual($this->manifest17->getConflicts(), array());
}
- public function testElggPluginManifestGetAdminInterface() {
- $this->assertEqual($this->manifest18->getAdminInterface(), 'simple');
- }
-
public function testElggPluginManifestGetActivateOnInstall() {
$this->assertEqual($this->manifest18->getActivateOnInstall(), true);
}
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php
index c04bc60ff..c13b4c731 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())));
@@ -134,6 +134,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
// clean up
$this->assertTrue($this->entity->delete());
+ remove_subtype('site', 'testing');
}
public function testElggEntityCache() {
@@ -226,8 +227,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 +237,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
@@ -278,6 +279,10 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
$this->entity->$name = $md;
$this->assertEqual($md, $this->entity->$name);
+
+ if ($save) {
+ $this->assertTrue($this->entity->delete());
+ }
}
}
@@ -292,6 +297,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 +316,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 +335,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 +355,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);
}
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();
}
/**
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;
diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php
index 23d6d1dc6..2bfc37558 100644
--- a/engine/tests/regression/trac_bugs.php
+++ b/engine/tests/regression/trac_bugs.php
@@ -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);
diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml
index 23f0fa0bf..445a41c2e 100644
--- a/engine/tests/test_files/plugin_18/manifest.xml
+++ b/engine/tests/test_files/plugin_18/manifest.xml
@@ -34,7 +34,6 @@
<category>ServiceAPI</category>
- <admin_interface>simple</admin_interface>
<activate_on_install>true</activate_on_install>
<requires>
diff --git a/engine/tests/ui/submenu.php b/engine/tests/ui/submenu.php
deleted file mode 100644
index b401620f6..000000000
--- a/engine/tests/ui/submenu.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * 1.8 submenu test.
- *
- * Submenu needs to be able to support being added out of order.
- * Children can be added before parents.
- * Children of parents never defined are never shown.
- *
- * Test against:
- * different contexts
- * different groups
- * old add_submenu_item() wrapper.
- *
- */
-
-/*
- * Tests need to be ported to new menu system
- *
-
-require_once('../../start.php');
-
-$url = "engine/tests/ui/submenu.php";
-
-$items = array(
- array(
- 'text' => 'Upper level 1',
- 'href' => "$url?upper_level_1",
- 'id' => 'ul1'
- ),
- array(
- 'text' => 'CD (No link)',
- 'parent_id' => 'cup',
- 'id' => 'cd',
- ),
- array(
- 'text' => 'Sub CD',
- 'href' => "$url?sub_cd",
- 'parent_id' => 'cd'
- ),
- array(
- 'text' => 'Cup',
- 'href' => "$url?cup",
- 'id' => 'cup'
- ),
- array(
- 'text' => 'Phone',
- 'href' => "$url?phone",
- 'id' => 'phone',
- 'parent_id' => 'cup'
- ),
- array(
- 'text' => 'Wallet',
- 'href' => "$url?wallet",
- 'id' => 'wallet',
- 'parent_id' => 'phone'
- ),
- array(
- 'text' => 'Upper level',
- 'href' => "$url?upper_level",
- 'id' => 'ul'
- ),
- array(
- 'text' => 'Sub Upper level',
- 'href' => "$url?sub_upper_level",
- 'parent_id' => 'ul'
- ),
- array(
- 'text' => 'Root',
- 'href' => $url,
- ),
-
- array(
- 'text' => 'I am an orphan',
- 'href' => 'http://google.com',
- 'parent_id' => 'missing_parent'
- ),
-
- array(
- 'text' => 'JS Test',
- 'href' => 'http://elgg.org',
- 'vars' => array('js' => 'onclick="alert(\'Link to \' + $(this).attr(\'href\') + \'!\'); return false;"')
- )
-);
-
-foreach ($items as $item) {
- elgg_add_submenu_item($item, 'main');
-}
-
-add_submenu_item('Old Onclick Test', 'http://elgg.com', NULL, TRUE);
-add_submenu_item('Old Selected Test', 'http://elgg.com', NULL, '', TRUE);
-
-
-elgg_add_submenu_item(array('text' => 'Not Main Test', 'href' => "$url?not_main_test"), 'not_main', 'new_menu');
-elgg_add_submenu_item(array('text' => 'Not Main C Test', 'href' => "$url?not_main_c_test"), 'not_main', 'new_menu');
-
-elgg_add_submenu_item(array('text' => 'All test', 'href' => "$url?all"), 'all');
-
-//elgg_set_context('not_main');
-
-$body = elgg_view_layout('one_sidebar', array('content' => 'Look right.'));
-echo elgg_view_page('Submenu Test', $body);
-
-*/