aboutsummaryrefslogtreecommitdiff
path: root/engine/tests/api
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-18 02:08:05 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-18 02:08:05 +0000
commitf0038ed3feb06b4077f20d2f407f6903799b5d29 (patch)
tree3015e6043038936b70e468f00ece9d36b7496f81 /engine/tests/api
parent580e6de308988861562de867714e1bb74dce2226 (diff)
downloadelgg-f0038ed3feb06b4077f20d2f407f6903799b5d29.tar.gz
elgg-f0038ed3feb06b4077f20d2f407f6903799b5d29.tar.bz2
Refs #2165 added elgg_get_entities_from_private_settings()
git-svn-id: http://code.elgg.org/elgg/trunk@7335 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/tests/api')
-rw-r--r--engine/tests/api/entity_getter_functions.php85
1 files changed, 85 insertions, 0 deletions
diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php
index ce14bd4ee..07fb1fd8c 100644
--- a/engine/tests/api/entity_getter_functions.php
+++ b/engine/tests/api/entity_getter_functions.php
@@ -2361,4 +2361,89 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
get_entity($guid)->delete();
}
}
+
+ /**
+ * Private settings
+ */
+ public function testElggApiGettersEntitiesFromPrivateSettings() {
+
+ // create some test private settings
+ $setting_name = 'test_setting_name_' . rand();
+ $setting_value = rand(1000, 9999);
+ $setting_name2 = 'test_setting_name_' . rand();
+ $setting_value2 = rand(1000, 9999);
+
+ $subtypes = $this->getRandomValidSubtypes(array('object'), 1);
+ $subtype = $subtypes[0];
+ $guids = array();
+
+ // our targets
+ $valid = new ElggObject();
+ $valid->subtype = $subtype;
+ $valid->save();
+ $guids[] = $valid->getGUID();
+ set_private_setting($valid->getGUID(), $setting_name, $setting_value);
+ set_private_setting($valid->getGUID(), $setting_name2, $setting_value2);
+
+ $valid2 = new ElggObject();
+ $valid2->subtype = $subtype;
+ $valid2->save();
+ $guids[] = $valid2->getGUID();
+ set_private_setting($valid2->getGUID(), $setting_name, $setting_value);
+ set_private_setting($valid2->getGUID(), $setting_name2, $setting_value2);
+
+ // simple test with name
+ $options = array(
+ 'private_setting_name' => $setting_name
+ );
+
+ $entities = elgg_get_entities_from_private_settings($options);
+
+ foreach ($entities as $entity) {
+ $this->assertTrue(in_array($entity->getGUID(), $guids));
+ $value = get_private_setting($entity->getGUID(), $setting_name);
+ $this->assertEqual($value, $setting_value);
+ }
+
+ // simple test with value
+ $options = array(
+ 'private_setting_value' => $setting_value
+ );
+
+ $entities = elgg_get_entities_from_private_settings($options);
+
+ foreach ($entities as $entity) {
+ $this->assertTrue(in_array($entity->getGUID(), $guids));
+ $value = get_private_setting($entity->getGUID(), $setting_name);
+ $this->assertEqual($value, $setting_value);
+ }
+
+ // test pairs
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => $subtype,
+ 'private_setting_name_value_pairs' => array(
+ array(
+ 'name' => $setting_name,
+ 'value' => $setting_value
+ ),
+ array(
+ 'name' => $setting_name2,
+ 'value' => $setting_value2
+ )
+ )
+ );
+
+ $entities = elgg_get_entities_from_private_settings($options);
+ $this->assertEqual(2, count($entities));
+ foreach ($entities as $entity) {
+ $this->assertTrue(in_array($entity->getGUID(), $guids));
+ }
+
+ foreach ($guids as $guid) {
+ if ($e = get_entity($guid)) {
+ $e->delete();
+ }
+ }
+ }
}