aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/entities.php4
-rw-r--r--engine/lib/objects.php12
-rw-r--r--engine/tests/objects/entities.php5
-rw-r--r--engine/tests/objects/objects.php68
-rw-r--r--engine/tests/test_skeleton.php6
5 files changed, 87 insertions, 8 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 779efb7af..b72eb6ff0 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -2787,8 +2787,8 @@
*/
function entities_test($hook, $type, $value, $params) {
global $CONFIG;
- $params[] = $CONFIG->path . 'engine/tests/objects/entities.php';
- return $params;
+ $value[] = $CONFIG->path . 'engine/tests/objects/entities.php';
+ return $value;
}
/**
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index 7e7e956a4..8d09b178b 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -364,5 +364,13 @@
return get_entities_from_relationship("member_of_site", $object_guid, false, "site", "", 0, "time_created desc", $limit, $offset);
}
-
-?> \ No newline at end of file
+
+/**
+ * Runs unit tests for ElggObject
+ */
+register_plugin_hook('unit_test', 'system', 'objects_test');
+function objects_test($hook, $type, $value, $params) {
+ global $CONFIG;
+ $value[] = "{$CONFIG->path}engine/tests/objects/objects.php";
+ return $value;
+}
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php
index be9c11a6f..f3f20024b 100644
--- a/engine/tests/objects/entities.php
+++ b/engine/tests/objects/entities.php
@@ -112,6 +112,11 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
$annotations = $this->entity->getAnnotations('non_existent');
$this->assertIsA($annotations[0], 'ElggAnnotation');
$this->assertIdentical($annotations[0]->name, 'non_existent');
+ $this->assertEqual($this->entity->countAnnotations('non_existent'), 1);
+
+ // clear annotation
+ $this->assertTrue($this->entity->clearAnnotations());
+ $this->assertEqual($this->entity->countAnnotations('non_existent'), 0);
// clean up
$this->assertTrue($this->entity->delete());
diff --git a/engine/tests/objects/objects.php b/engine/tests/objects/objects.php
new file mode 100644
index 000000000..c9600ab6e
--- /dev/null
+++ b/engine/tests/objects/objects.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Elgg Test ElggObject
+ *
+ * @package Elgg
+ * @subpackage Test
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ */
+class ElggCoreObjectTest extends ElggCoreUnitTest {
+
+ /**
+ * Called before each test object.
+ */
+ public function __construct() {
+ parent::__construct();
+ }
+
+ /**
+ * Called before each test method.
+ */
+ public function setUp() {
+ $this->entity = new ElggObjectTest();
+ }
+
+ /**
+ * Called after each test method.
+ */
+ public function tearDown() {
+ unset($this->entity);
+ }
+
+ /**
+ * Called after each test object.
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * A basic test that will be called and fail.
+ */
+ public function testElggEntityConstructor() {
+ $attributes = array();
+ $attributes['guid'] = '';
+ $attributes['type'] = 'object';
+ $attributes['subtype'] = '';
+ $attributes['owner_guid'] = get_loggedin_userid();
+ $attributes['container_guid'] = get_loggedin_userid();
+ $attributes['site_guid'] = 0;
+ $attributes['access_id'] = ACCESS_PRIVATE;
+ $attributes['time_created'] = '';
+ $attributes['time_updated'] = '';
+ $attributes['enabled'] = 'yes';
+ $attributes['tables_split'] = 2;
+ $attributes['tables_loaded'] = 0;
+ $attributes['title'] = '';
+ $attributes['description'] = '';
+
+ $this->assertIdentical($this->entity->expose_attributes(), $attributes);
+ }
+}
+
+class ElggObjectTest extends ElggObject {
+ public function expose_attributes() {
+ return $this->attributes;
+ }
+}
diff --git a/engine/tests/test_skeleton.php b/engine/tests/test_skeleton.php
index 494887bc2..42bbd4ba5 100644
--- a/engine/tests/test_skeleton.php
+++ b/engine/tests/test_skeleton.php
@@ -13,8 +13,7 @@ class ElggCoreSkeletonTest extends ElggCoreUnitTest {
* Called before each test object.
*/
public function __construct() {
- // first, hook into ElggCoreUnitTest::__construct()
- $this->__construct();
+ parent::__construct();
}
/**
@@ -35,8 +34,7 @@ class ElggCoreSkeletonTest extends ElggCoreUnitTest {
* Called after each test object.
*/
public function __destruct() {
- // hook into ElggCoreUnitTest::__destruct();
- $this->__destruct();
+ parent::__destruct();
}
/**