aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggEntity.php3
-rw-r--r--engine/classes/ElggGroup.php9
-rw-r--r--engine/classes/ElggObject.php5
-rw-r--r--engine/classes/ElggPluginManifest.php2
-rw-r--r--engine/classes/ElggSite.php5
-rw-r--r--engine/classes/ElggUser.php5
-rw-r--r--engine/lib/access.php5
-rw-r--r--engine/lib/elgglib.php5
-rw-r--r--engine/lib/entities.php21
-rw-r--r--engine/lib/metastrings.php2
-rw-r--r--engine/lib/relationships.php2
-rw-r--r--engine/lib/river.php30
-rw-r--r--engine/lib/user_settings.php4
-rw-r--r--engine/lib/users.php7
-rw-r--r--engine/lib/views.php1
-rw-r--r--engine/tests/api/access_collections.php4
-rw-r--r--engine/tests/api/entity_getter_functions.php71
-rw-r--r--engine/tests/api/helpers.php6
-rw-r--r--engine/tests/api/metadata.php4
-rw-r--r--engine/tests/api/metastrings.php10
-rw-r--r--engine/tests/api/plugins.php49
-rw-r--r--engine/tests/objects/entities.php28
-rw-r--r--engine/tests/objects/sites.php9
-rw-r--r--engine/tests/objects/users.php5
-rw-r--r--engine/tests/test_files/plugin_18/manifest.xml4
-rw-r--r--engine/tests/test_skeleton.php3
26 files changed, 176 insertions, 123 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php
index fdf2a80ea..df87082fe 100644
--- a/engine/classes/ElggEntity.php
+++ b/engine/classes/ElggEntity.php
@@ -1335,6 +1335,9 @@ abstract class ElggEntity extends ElggData implements
$this->attributes['tables_loaded']++;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
// Cache object handle
if ($this->attributes['guid']) {
cache_entity($this);
diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php
index 49ba27204..0190e5eac 100644
--- a/engine/classes/ElggGroup.php
+++ b/engine/classes/ElggGroup.php
@@ -309,7 +309,7 @@ class ElggGroup extends ElggEntity
*
* @param ElggUser $user User
*
- * @return void
+ * @return bool
*/
public function leave(ElggUser $user) {
return leave_group($this->getGUID(), $user->getGUID());
@@ -322,7 +322,7 @@ class ElggGroup extends ElggEntity
*
* @param int $guid GUID of an ElggGroup entity
*
- * @return true
+ * @return bool
*/
protected function load($guid) {
// Test to see if we have the generic stuff
@@ -340,7 +340,7 @@ class ElggGroup extends ElggEntity
$row = get_group_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -349,6 +349,9 @@ class ElggGroup extends ElggEntity
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php
index caccfb038..0b8340697 100644
--- a/engine/classes/ElggObject.php
+++ b/engine/classes/ElggObject.php
@@ -110,7 +110,7 @@ class ElggObject extends ElggEntity {
$row = get_object_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -119,6 +119,9 @@ class ElggObject extends ElggEntity {
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php
index eacc16455..7592eb667 100644
--- a/engine/classes/ElggPluginManifest.php
+++ b/engine/classes/ElggPluginManifest.php
@@ -553,7 +553,7 @@ class ElggPluginManifest {
}
/**
- * Returns the admin interface to use.
+ * Should this plugin be activated when Elgg is installed
*
* @return bool
*/
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index 16b80b9d3..5c44d4076 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -128,7 +128,7 @@ class ElggSite extends ElggEntity {
$row = get_site_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -137,6 +137,9 @@ class ElggSite extends ElggEntity {
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php
index 75ac008f6..a1c7147a5 100644
--- a/engine/classes/ElggUser.php
+++ b/engine/classes/ElggUser.php
@@ -114,7 +114,7 @@ class ElggUser extends ElggEntity
$row = get_user_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -123,6 +123,9 @@ class ElggUser extends ElggEntity
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 97f744fb9..08b9283cd 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -610,8 +610,7 @@ function delete_access_collection($collection_id) {
WHERE id = {$collection_id}";
$result = delete_data($q);
-
- return $result;
+ return (bool)$result;
}
/**
@@ -718,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) {
WHERE access_collection_id = {$collection_id}
AND user_guid = {$user_guid}";
- return delete_data($q);
+ return (bool)delete_data($q);
}
/**
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 08b346960..57d602450 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -107,7 +107,10 @@ function elgg_load_library($name) {
}
if (!include_once($CONFIG->libraries[$name])) {
- $error = elgg_echo('InvalidParameterException:LibraryNotRegistered', array($name));
+ $error = elgg_echo('InvalidParameterException:LibraryNotFound', array(
+ $name,
+ $CONFIG->libraries[$name])
+ );
throw new InvalidParameterException($error);
}
}
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index fd2b0e9f9..f7ae108ed 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -124,8 +124,6 @@ function retrieve_cached_entity_row($guid) {
* @internal Subtypes are stored in the entity_subtypes table. There is a foreign
* key in the entities table.
*
- * @todo Move to a nicer place?
- *
* @param string $type Type
* @param string $subtype Subtype
*
@@ -144,7 +142,7 @@ function get_subtype_id($type, $subtype) {
return FALSE;
}
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before hitting database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -163,8 +161,6 @@ function get_subtype_id($type, $subtype) {
/**
* Return string name for a given subtype ID.
*
- * @todo Move to a nicer place?
- *
* @param int $subtype_id Subtype ID
*
* @return string Subtype name
@@ -199,11 +195,11 @@ function get_subtype_from_id($subtype_id) {
}
/**
- * Return a classname for a registered type and subtype.
+ * Return the class name for a registered type and subtype.
*
* Entities can be registered to always be loaded as a certain class
- * with {@link register_entity_subtype()}. This function returns
- * the class name if found, and NULL if not.
+ * with add_subtype() or update_subtype(). This function returns the class
+ * name if found and NULL if not.
*
* @param string $type The type
* @param string $subtype The subtype
@@ -219,7 +215,7 @@ function get_subtype_class($type, $subtype) {
$type = sanitise_string($type);
$subtype = sanitise_string($subtype);
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before going to the database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -236,7 +232,7 @@ function get_subtype_class($type, $subtype) {
}
/**
- * Returns the classname for a subtype id.
+ * Returns the class name for a subtype id.
*
* @param int $subtype_id The subtype id
*
@@ -279,6 +275,9 @@ function get_subtype_class_from_id($subtype_id) {
* it will be loaded as that class automatically when retrieved from the database with
* {@link get_entity()}.
*
+ * @warning This function cannot be used to change the class for a type-subtype pair.
+ * Use update_subtype() for that.
+ *
* @param string $type The type you're subtyping (site, user, object, or group)
* @param string $subtype The subtype
* @param string $class Optional class name for the object
@@ -1563,7 +1562,7 @@ function delete_entity($guid, $recursive = true) {
}
}
- return $res;
+ return (bool)$res;
}
}
}
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 9dccec700..9fe9b4bff 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) {
}
if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) {
- return delete_data("DELETE from $table where id=$id");
+ return (bool)delete_data("DELETE from $table where id=$id");
}
}
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 3578f0cb8..5b7080b56 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -158,7 +158,7 @@ function remove_entity_relationship($guid_one, $relationship, $guid_two) {
and relationship='$relationship'
and guid_two=$guid_two";
- return delete_data($query);
+ return (bool)delete_data($query);
} else {
return false;
}
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 466eca253..02d52dea1 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -447,7 +447,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
return '';
}
- $wheres = array();
+ $types_wheres = array();
+ $subtypes_wheres = array();
// if no pairs, use types and subtypes
if (!is_array($pairs)) {
@@ -457,7 +458,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($types as $type) {
$type = sanitise_string($type);
- $wheres[] = "({$table}.type = '$type')";
+ $types_wheres[] = "({$table}.type = '$type')";
}
}
@@ -467,13 +468,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($subtypes as $subtype) {
$subtype = sanitise_string($subtype);
- $wheres[] = "({$table}.subtype = '$subtype')";
+ $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
}
}
- if (is_array($wheres) && count($wheres)) {
- $wheres = array(implode(' OR ', $wheres));
+ if (is_array($types_wheres) && count($types_wheres)) {
+ $types_wheres = array(implode(' OR ', $types_wheres));
}
+
+ if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
+ $subtypes_wheres = array(implode(' OR ', $subtypes_wheres));
+ }
+
+ $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
+
} else {
// using type/subtype pairs
foreach ($pairs as $paired_type => $paired_subtypes) {
@@ -611,6 +619,16 @@ function elgg_river_page_handler($page) {
}
/**
+ * Register river unit tests
+ * @access private
+ */
+function elgg_river_test($hook, $type, $value) {
+ global $CONFIG;
+ $value[] = $CONFIG->path . 'engine/tests/api/river.php';
+ return $value;
+}
+
+/**
* Initialize river library
* @access private
*/
@@ -620,6 +638,8 @@ function elgg_river_init() {
elgg_register_menu_item('site', $item);
elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
+
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test');
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php
index 1e2d6db10..c71670357 100644
--- a/engine/lib/user_settings.php
+++ b/engine/lib/user_settings.php
@@ -265,8 +265,8 @@ function elgg_set_user_default_access() {
* @access private
*/
function usersettings_pagesetup() {
- if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) {
- $user = elgg_get_logged_in_user_entity();
+ if (elgg_get_context() == "settings") {
+ $user = elgg_get_page_owner_entity();
$params = array(
'name' => '1_account',
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 9cb8ddfa7..3a86c1faa 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -565,6 +565,8 @@ function get_user_by_username($username) {
$entity = get_data_row($query, 'entity_row_to_elggstar');
if ($entity) {
$USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid;
+ } else {
+ $entity = false;
}
return $entity;
@@ -1281,6 +1283,11 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('admin');
$return[] = $item;
+
+ $url = "settings/user/$user->username";
+ $item = new ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url);
+ $item->setSection('admin');
+ $return[] = $item;
}
return $return;
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 0f806b8be..d3c9ff551 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1602,6 +1602,7 @@ function elgg_views_boot() {
elgg_load_js('elgg');
elgg_register_simplecache_view('js/lightbox');
+ elgg_register_simplecache_view('css/lightbox');
$lightbox_js_url = elgg_get_simplecache_url('js', 'lightbox');
elgg_register_js('lightbox', $lightbox_js_url);
$lightbox_css_url = elgg_get_simplecache_url('css', 'lightbox');
diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php
index 0c37fa779..bea995a6e 100644
--- a/engine/tests/api/access_collections.php
+++ b/engine/tests/api/access_collections.php
@@ -76,7 +76,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
$q = "SELECT * FROM {$this->dbPrefix}access_collections WHERE id = $acl_id";
$data = get_data($q);
- $this->assertFalse($data);
+ $this->assertIdentical(array(), $data);
}
}
@@ -88,7 +88,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
if ($result) {
$result = remove_user_from_access_collection($this->user->guid, $acl_id);
- $this->assertTrue($result);
+ $this->assertIdentical(true, $result);
}
delete_access_collection($acl_id);
diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php
index e7906d3c8..9db248de9 100644
--- a/engine/tests/api/entity_getter_functions.php
+++ b/engine/tests/api/entity_getter_functions.php
@@ -175,9 +175,10 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
/**
+ * Get a mix of valid and invalid types
*
- * @param unknown_type $num
- * @return unknown_type
+ * @param int $num
+ * @return array
*/
public function getRandomMixedTypes($num = 2) {
$have_valid = $have_invalid = false;
@@ -196,8 +197,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
* Get random mix of valid and invalid subtypes for types given.
*
* @param array $types
- * @param unknown_type $num
- * @return unknown_type
+ * @param int $num
+ * @return array
*/
public function getRandomMixedSubtypes(array $types, $num = 2) {
$types_c = count($types);
@@ -230,8 +231,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
/**
* Creates random annotations on $entity
*
- * @param unknown_type $entity
- * @param unknown_type $max
+ * @param ElggEntity $entity
+ * @param int $max
*/
public function createRandomAnnotations($entity, $max = 1) {
$annotations = array();
@@ -563,7 +564,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
* TYPE_SUBTYPE_PAIRS
***************************/
-
+ /**
+ * Valid type, valid subtype pairs
+ */
public function testElggAPIGettersTSPValidTypeValidSubtype() {
$type_num = 1;
$subtype_num = 1;
@@ -586,6 +589,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
+ /**
+ * Valid type, multiple valid subtypes
+ */
public function testElggAPIGettersTSPValidTypeValidPluralSubtype() {
$type_num = 1;
$subtype_num = 3;
@@ -608,6 +614,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
+ /**
+ * Valid type, both valid and invalid subtypes
+ */
public function testElggAPIGettersTSPValidTypeMixedPluralSubtype() {
$type_num = 1;
$valid_subtype_num = 2;
@@ -635,9 +644,6 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
-
-
-
/****************************
* FALSE-RETURNING TESTS
****************************
@@ -652,8 +658,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
*/
- /*
- * Test invalid types.
+ /**
+ * Test invalid types with singular 'type'.
*/
public function testElggApiGettersInvalidTypeUsingType() {
$type_arr = $this->getRandomInvalids();
@@ -667,7 +673,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$this->assertFalse($es);
}
-
+ /**
+ * Test invalid types with plural 'types'.
+ */
public function testElggApiGettersInvalidTypeUsingTypesAsString() {
$type_arr = $this->getRandomInvalids();
$type = $type_arr[0];
@@ -680,8 +688,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$this->assertFalse($es);
}
+ /**
+ * Test invalid types with plural 'types' and an array of a single type
+ */
public function testElggApiGettersInvalidTypeUsingTypesAsArray() {
- $type_arr = $this->getRandomInvalids();
+ $type_arr = $this->getRandomInvalids(1);
$options = array(
'types' => $type_arr
@@ -691,6 +702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$this->assertFalse($es);
}
+ /**
+ * Test invalid types with plural 'types' and an array of a two types
+ */
public function testElggApiGettersInvalidTypes() {
$type_arr = $this->getRandomInvalids(2);
@@ -1053,7 +1067,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1081,7 +1095,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1214,7 +1228,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
- function testElggApiGettersEntityMetadatavalueInvalidSingle() {
+ function testElggApiGettersEntityMetadataValueInvalidSingle() {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
$md_name = 'test_metadata_name_' . rand();
@@ -1235,7 +1249,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1263,7 +1277,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1641,6 +1655,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
+ /**
+ * Name value pair with valid name and invalid value
+ */
function testElggApiGettersEntityMetadataNVPValidNInvalidV() {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
@@ -1676,7 +1693,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
foreach ($guids as $guid) {
if ($e = get_entity($guid)) {
@@ -1685,7 +1702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
-
+ /**
+ * Name value pair with invalid name and valid value
+ */
function testElggApiGettersEntityMetadataNVPInvalidNValidV() {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
@@ -1721,7 +1740,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
foreach ($guids as $guid) {
if ($e = get_entity($guid)) {
@@ -2083,7 +2102,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities_from_relationship($options);
$this->assertTrue(is_array($es));
- $this->assertTrue(count($es), 1);
+ $this->assertIdentical(count($es), 1);
foreach ($es as $e) {
$this->assertEqual($guids[1], $e->guid);
@@ -2115,7 +2134,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities_from_relationship($options);
$this->assertTrue(is_array($es));
- $this->assertTrue(count($es), 1);
+ $this->assertIdentical(count($es), 1);
foreach ($es as $e) {
$this->assertEqual($guids[1], $e->guid);
@@ -2151,7 +2170,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities_from_relationship($options);
$this->assertTrue(is_array($es));
- $this->assertTrue(count($es), 1);
+ $this->assertIdentical(count($es), 1);
foreach ($es as $e) {
$this->assertEqual($guids[1], $e->guid);
@@ -2578,7 +2597,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
foreach ($fan_entities as $fan_entity) {
$this->assertTrue(in_array($fan_entity->guid, $relationships[$e->guid]));
- $this->assertTrue(check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid));
+ $this->assertNotIdentical(false, check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid));
}
}
}
diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php
index f48f91faf..77205138d 100644
--- a/engine/tests/api/helpers.php
+++ b/engine/tests/api/helpers.php
@@ -127,7 +127,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertIdentical('http://test1.com', $item->url);
// send a bad url
- $result = @elgg_register_js('bad');
+ $result = elgg_register_js('bad', null);
$this->assertFalse($result);
}
@@ -351,7 +351,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$test_elements = $pl->getElements();
// make sure it's gone.
- $this->assertTrue(2, count($test_elements));
+ $this->assertEqual(2, count($test_elements));
$this->assertIdentical($elements[0], $test_elements[0]);
$this->assertIdentical($elements[2], $test_elements[2]);
}
@@ -369,7 +369,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$pl->add($element, $priority);
}
- $this->assertTrue($pl->move($elements[-5], 10));
+ $this->assertEqual($pl->move($elements[-5], 10), 10);
// check it's at the new place
$this->assertIdentical($elements[-5], $pl->getElement(10));
diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php
index 7897b8d47..f5b615ca8 100644
--- a/engine/tests/api/metadata.php
+++ b/engine/tests/api/metadata.php
@@ -58,11 +58,11 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest {
$this->create_metastring('tested');
// create_metadata returns id of metadata on success
- $this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
+ $this->assertNotEqual(false, create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
// check value with improper case
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
- $this->assertFalse(elgg_get_entities_from_metadata($options));
+ $this->assertIdentical(array(), elgg_get_entities_from_metadata($options));
// compare forced case with ignored case
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php
index 9b5d7ee4e..a96388217 100644
--- a/engine/tests/api/metastrings.php
+++ b/engine/tests/api/metastrings.php
@@ -68,9 +68,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testDeleteByID() {
$db_prefix = elgg_get_config('dbprefix');
$annotations = $this->createAnnotations(1);
@@ -83,8 +80,8 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest {
$test = get_data($q);
$this->assertEqual($test[0]->id, $id);
- $this->assertTrue(elgg_delete_metastring_based_object_by_id($id, $type));
- $this->assertFalse(get_data($q));
+ $this->assertIdentical(true, elgg_delete_metastring_based_object_by_id($id, $type));
+ $this->assertIdentical(array(), get_data($q));
}
}
@@ -101,9 +98,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest {
}
}
- /**
- * A basic test that will be called and fail.
- */
public function testEnableDisableByID() {
$db_prefix = elgg_get_config('dbprefix');
$annotations = $this->createAnnotations(1);
diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php
index a0faaff0e..8ecb0a46c 100644
--- a/engine/tests/api/plugins.php
+++ b/engine/tests/api/plugins.php
@@ -93,22 +93,23 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
),
'conflicts' => array(
- array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.0)
+ array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.0')
),
'provides' => array(
- array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3),
- array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0)
+ array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'),
+ array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0')
),
'suggests' => array(
- array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => 1.0),
+ array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0'),
),
- 'activate_on_install' => true
+ // string because we are reading from a file
+ 'activate_on_install' => 'true',
);
- $this->assertEqual($this->manifest18->getManifest(), $manifest_array);
+ $this->assertIdentical($this->manifest18->getManifest(), $manifest_array);
}
public function testElggPluginManifest17() {
@@ -123,7 +124,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
'name' => 'Plugin Test 17',
);
- $this->assertEqual($this->manifest17->getManifest(), $manifest_array);
+ $this->assertIdentical($this->manifest17->getManifest(), $manifest_array);
}
@@ -180,7 +181,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'),
array('type' => 'elgg_release', 'version' => '1.8-svn', 'comparison' => 'ge'),
array('type' => 'php_extension', 'name' => 'gd', 'version' => '', 'comparison' => '='),
- array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 'off', 'comparison' => '='),
+ array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 0, 'comparison' => '='),
array('type' => 'php_extension', 'name' => 'made_up', 'version' => '1.0', 'comparison' => '='),
array('type' => 'plugin', 'name' => 'fake_plugin', 'version' => '1.0', 'comparison' => 'ge'),
array('type' => 'plugin', 'name' => 'profile', 'version' => '1.0', 'comparison' => 'ge'),
@@ -188,13 +189,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'priority', 'priority' => 'after', 'plugin' => 'profile'),
);
- $this->assertEqual($this->package18->getManifest()->getRequires(), $requires);
+ $this->assertIdentical($this->package18->getManifest()->getRequires(), $requires);
$requires = array(
array('type' => 'elgg_version', 'version' => '2009030702', 'comparison' => 'ge')
);
- $this->assertEqual($this->package17->getManifest()->getRequires(), $requires);
+ $this->assertIdentical($this->package17->getManifest()->getRequires(), $requires);
}
public function testElggPluginManifestGetSuggests() {
@@ -202,11 +203,11 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0', 'comparison' => 'ge'),
);
- $this->assertEqual($this->package18->getManifest()->getSuggests(), $suggests);
+ $this->assertIdentical($this->package18->getManifest()->getSuggests(), $suggests);
$suggests = array();
- $this->assertEqual($this->package17->getManifest()->getSuggests(), $suggests);
+ $this->assertIdentical($this->package17->getManifest()->getSuggests(), $suggests);
}
public function testElggPluginManifestGetDescription() {
@@ -219,8 +220,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
'Admin', 'ServiceAPI'
);
- $this->assertEqual($this->package18->getManifest()->getCategories(), $categories);
- $this->assertEqual($this->package17->getManifest()->getCategories(), array());
+ $this->assertIdentical($this->package18->getManifest()->getCategories(), $categories);
+ $this->assertIdentical($this->package17->getManifest()->getCategories(), array());
}
public function testElggPluginManifestGetScreenshots() {
@@ -229,25 +230,25 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('description' => 'Fun things to do 2', 'path' => 'graphics/plugin_ss2.png'),
);
- $this->assertEqual($this->package18->getManifest()->getScreenshots(), $screenshots);
- $this->assertEqual($this->package17->getManifest()->getScreenshots(), array());
+ $this->assertIdentical($this->package18->getManifest()->getScreenshots(), $screenshots);
+ $this->assertIdentical($this->package17->getManifest()->getScreenshots(), array());
}
public function testElggPluginManifestGetProvides() {
$provides = array(
- array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3),
- array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0),
- array('type' => 'plugin', 'name' => 'plugin_18', 'version' => 1.0)
+ array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'),
+ array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0'),
+ array('type' => 'plugin', 'name' => 'plugin_18', 'version' => '1.0')
);
- $this->assertEqual($this->package18->getManifest()->getProvides(), $provides);
+ $this->assertIdentical($this->package18->getManifest()->getProvides(), $provides);
$provides = array(
array('type' => 'plugin', 'name' => 'plugin_17', 'version' => '1.0')
);
- $this->assertEqual($this->package17->getManifest()->getProvides(), $provides);
+ $this->assertIdentical($this->package17->getManifest()->getProvides(), $provides);
}
public function testElggPluginManifestGetConflicts() {
@@ -260,12 +261,12 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
)
);
- $this->assertEqual($this->manifest18->getConflicts(), $conflicts);
- $this->assertEqual($this->manifest17->getConflicts(), array());
+ $this->assertIdentical($this->manifest18->getConflicts(), $conflicts);
+ $this->assertIdentical($this->manifest17->getConflicts(), array());
}
public function testElggPluginManifestGetActivateOnInstall() {
- $this->assertEqual($this->manifest18->getActivateOnInstall(), true);
+ $this->assertIdentical($this->manifest18->getActivateOnInstall(), true);
}
// ElggPluginPackage
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php
index c13b4c731..1772f7c1a 100644
--- a/engine/tests/objects/entities.php
+++ b/engine/tests/objects/entities.php
@@ -89,21 +89,21 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
$this->assertFalse(isset($this->entity->non_existent));
// create metadata
- $this->assertTrue($this->entity->non_existent = 'testing');
+ $this->entity->existent = 'testing';
+ $this->assertIdentical($this->entity->existent, 'testing');
// check metadata set
- $this->assertTrue(isset($this->entity->non_existent));
- $this->assertIdentical($this->entity->non_existent, 'testing');
- $this->assertIdentical($this->entity->getMetaData('non_existent'), 'testing');
+ $this->assertTrue(isset($this->entity->existent));
+ $this->assertIdentical($this->entity->getMetaData('existent'), 'testing');
// check internal metadata array
$metadata = $this->entity->expose_metadata();
- $this->assertIdentical($metadata['non_existent'], 'testing');
+ $this->assertIdentical($metadata['existent'], 'testing');
}
public function testElggEnityGetAndSetAnnotations() {
$this->assertFalse(array_key_exists('non_existent', $this->entity->expose_annotations()));
- $this->assertFalse($this->entity->getAnnotations('non_existent'));
+ $this->assertIdentical($this->entity->getAnnotations('non_existent'), array());
// set and check temp annotation
$this->assertTrue($this->entity->annotate('non_existent', 'testing'));
@@ -178,7 +178,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
$this->AssertEqual($this->entity->get('non_existent'), 'testing');
// clean up with delete
- $this->assertTrue($this->entity->delete());
+ $this->assertIdentical(true, $this->entity->delete());
}
public function testElggEntityDisableAndEnable() {
@@ -230,24 +230,26 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
// let's delete a non-existent metadata
$this->assertFalse($this->entity->deleteMetadata('important'));
- // let's add the meatadata
- $this->assertTrue($this->entity->important = 'indeed!');
- $this->assertTrue($this->entity->less_important = 'true, too!');
+ // let's add the metadata
+ $this->entity->important = 'indeed!';
+ $this->assertIdentical('indeed!', $this->entity->important);
+ $this->entity->less_important = 'true, too!';
+ $this->assertIdentical('true, too!', $this->entity->less_important);
$this->save_entity();
// test deleting incorrectly
// @link http://trac.elgg.org/ticket/2273
- $this->assertFalse($this->entity->deleteMetadata('impotent'));
+ $this->assertNull($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->deleteMetadata('important'));
- $this->assertEqual($this->entity->important, '');
+ $this->assertNull($this->entity->important);
// get rid of all metadata
$this->assertTrue($this->entity->deleteMetadata());
- $this->assertEqual($this->entity->less_important, '');
+ $this->assertNull($this->entity->less_important);
// clean up database
$this->assertTrue($this->entity->delete());
diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php
index e5acbb3f9..a01a661e3 100644
--- a/engine/tests/objects/sites.php
+++ b/engine/tests/objects/sites.php
@@ -36,9 +36,6 @@ class ElggCoreSiteTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testElggSiteConstructor() {
$attributes = array();
$attributes['guid'] = NULL;
@@ -66,8 +63,10 @@ class ElggCoreSiteTest extends ElggCoreUnitTest {
}
public function testElggSiteSaveAndDelete() {
- $this->assertTrue($this->site->save());
- $this->assertTrue($this->site->delete());
+ $guid = $this->site->save();
+ $this->assertIsA($guid, 'int');
+ $this->assertTrue($guid > 0);
+ $this->assertIdentical(true, $this->site->delete());
}
}
diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php
index d1533c3d2..a3573acb6 100644
--- a/engine/tests/objects/users.php
+++ b/engine/tests/objects/users.php
@@ -41,9 +41,6 @@ class ElggCoreUserTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testElggUserConstructor() {
$attributes = array();
$attributes['guid'] = NULL;
@@ -138,7 +135,7 @@ class ElggCoreUserTest extends ElggCoreUnitTest {
$guid = $this->user->save();
// delete object
- $this->assertTrue($this->user->delete());
+ $this->assertIdentical(true, $this->user->delete());
// check GUID not in database
$this->assertFalse($this->fetchUser($guid));
diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml
index e0776ffc1..9654b6422 100644
--- a/engine/tests/test_files/plugin_18/manifest.xml
+++ b/engine/tests/test_files/plugin_18/manifest.xml
@@ -34,8 +34,6 @@
<category>ServiceAPI</category>
- <activate_on_install>true</activate_on_install>
-
<requires>
<type>php_extension</type>
<name>gd</name>
@@ -102,4 +100,6 @@
<version>1.0</version>
</suggests>
+ <activate_on_install>true</activate_on_install>
+
</plugin_manifest>
diff --git a/engine/tests/test_skeleton.php b/engine/tests/test_skeleton.php
index e5ff557e5..5a5de89bb 100644
--- a/engine/tests/test_skeleton.php
+++ b/engine/tests/test_skeleton.php
@@ -49,9 +49,6 @@ class ElggCoreSkeletonTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testFailure() {
$this->assertTrue(FALSE);
}