aboutsummaryrefslogtreecommitdiff
path: root/engine/tests
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-17 19:43:49 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-17 19:43:49 +0000
commitb3012350e2d8dafaf696e2c472f8cf0ae5e1674b (patch)
treecc0dd15d97f2a8846448823eae1555d280e9623a /engine/tests
parentccb5a69319a6a367988534296c678c8abf322879 (diff)
downloadelgg-b3012350e2d8dafaf696e2c472f8cf0ae5e1674b.tar.gz
elgg-b3012350e2d8dafaf696e2c472f8cf0ae5e1674b.tar.bz2
Refs #1523: elgg_get_entities() uses the constants for defaults and conditionals. Added some tests to check for no subtypes. Updated the documentation.
git-svn-id: http://code.elgg.org/elgg/trunk@3946 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/tests')
-rw-r--r--engine/tests/api/entity_getter_functions.php98
1 files changed, 98 insertions, 0 deletions
diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php
index f3f892d79..c4706d3df 100644
--- a/engine/tests/api/entity_getter_functions.php
+++ b/engine/tests/api/entity_getter_functions.php
@@ -824,4 +824,102 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities($options);
$this->assertFalse($es);
}
+
+
+
+
+
+
+ public function testElggApiGettersEntityNoSubtype() {
+ // create an entity we can later delete.
+ // order by time created and limit by 1 should == this entity.
+
+ $e = new ElggObject();
+ $e->save();
+
+ $options = array(
+ 'type' => 'object',
+ 'limit' => 1,
+ 'order_by' => 'e.time_created desc'
+ );
+
+ // grab ourself again to fill out attributes.
+ $e = get_entity($e->getGUID());
+
+ $entities = elgg_get_entities($options);
+
+ $this->assertEqual(count($entities), 1);
+
+ foreach ($entities as $entity) {
+ $this->assertIdentical($e->getGUID(), $entity->getGUID());
+ }
+
+ $e->delete();
+ }
+
+ public function testElggApiGettersEntityNoValueSubtypeNotSet() {
+ // create an entity we can later delete.
+ // order by time created and limit by 1 should == this entity.
+
+ $e = new ElggObject();
+ $e->save();
+
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => ELGG_ENTITY_NO_VALUE,
+ 'limit' => 1,
+ 'order_by' => 'e.time_created desc'
+ );
+
+ // grab ourself again to fill out attributes.
+ $e = get_entity($e->getGUID());
+
+ $entities = elgg_get_entities($options);
+
+ $this->assertEqual(count($entities), 1);
+
+ foreach ($entities as $entity) {
+ $this->assertIdentical($e->getGUID(), $entity->getGUID());
+ }
+
+ $e->delete();
+ }
+
+ public function testElggApiGettersEntityNoValueSubtypeSet() {
+ global $CONFIG;
+ // create an entity we can later delete.
+ // order by time created and limit by 1 should == this entity.
+
+ $subtype = 'subtype_' . rand();
+
+ $e = new ElggObject();
+ $e->subtype = $subtype;
+ $e->save();
+
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => ELGG_ENTITIES_NO_VALUE,
+ 'limit' => 1,
+ 'order_by' => 'e.time_created desc'
+ );
+
+ // grab ourself again to fill out attributes.
+ $e = get_entity($e->getGUID());
+
+ $entities = elgg_get_entities($options);
+
+ $this->assertEqual(count($entities), 1);
+
+ // this entity should NOT be the entity we just created
+ // and should have no subtype
+ foreach ($entities as $entity) {
+ $this->assertNotEqual($e->getGUID(), $entity->getGUID());
+ $this->assertEqual($entity->subtype_id, 0);
+ }
+
+ $e->delete();
+
+ $q = "DELETE FROM {$CONFIG->dbprefix}entity_subtypes WHERE subtype = '$subtype'";
+ delete_data($q);
+ }
}