aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/tests/objects/metadata.php44
1 files changed, 26 insertions, 18 deletions
diff --git a/engine/tests/objects/metadata.php b/engine/tests/objects/metadata.php
index eb635db4a..cf39a186b 100644
--- a/engine/tests/objects/metadata.php
+++ b/engine/tests/objects/metadata.php
@@ -24,19 +24,19 @@ class ElggCoreMetadataTest extends ElggCoreUnitTest {
public function tearDown() {
// do not allow SimpleTest to interpret Elgg notices as exceptions
$this->swallowErrors();
-
+
unset($this->object);
}
public function testGetMetastringById() {
foreach (array('metaUnitTest', 'metaunittest', 'METAUNITTEST') as $string) {
- $this->create_metastring($string);
+ $this->create_metastring($string);
}
-
+
// lookup metastring id
$cs_ids = get_metastring_id('metaUnitTest', TRUE);
$this->assertEqual($cs_ids, $this->metastrings['metaUnitTest']);
-
+
// lookup all metastrings, ignoring case
$cs_ids = get_metastring_id('metaUnitTest', FALSE);
$this->assertEqual(count($cs_ids), 3);
@@ -45,47 +45,55 @@ class ElggCoreMetadataTest extends ElggCoreUnitTest {
{
$this->assertTrue(in_array($string, $this->metastrings));
}
-
+
// clean up
$this->delete_metastrings();
}
-
+
public function testGetEntitiesFromMetadata() {
+ global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
+ $METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array();
+
$this->object->title = 'Meta Unit Test';
$this->object->save();
$this->create_metastring('metaUnitTest');
$this->create_metastring('tested');
+
$this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
-
+
// check value with improper case
$this->assertFalse(get_entities_from_metadata('metaUnitTest', 'Tested', '', '', 0, 10, 0, '', 0, FALSE, TRUE));
-
+
// compare forced case with ignored case
$case_true = get_entities_from_metadata('metaUnitTest', 'tested', '', '', 0, 10, 0, '', 0, FALSE, TRUE);
- $case_false = get_entities_from_metadata('metaUnitTest', 'Tested', '', '', 0, 10, 0, '', 0, FALSE, FALSE);
$this->assertIsA($case_true, 'array');
+
+ $case_false = get_entities_from_metadata('metaUnitTest', 'Tested', '', '', 0, 10, 0, '', 0, FALSE, FALSE);
$this->assertIsA($case_false, 'array');
+
$this->assertIdentical($case_true, $case_false);
-
+
// 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();
}
-
-
+
+
protected function create_metastring($string) {
- global $CONFIG;
-
+ global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
+ $METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array();
+
mysql_query("INSERT INTO {$CONFIG->dbprefix}metastrings (string) VALUES ('$string')");
$this->metastrings[$string] = mysql_insert_id();
}
-
+
protected function delete_metastrings() {
- global $CONFIG;
-
+ global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
+ $METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array();
+
$strings = implode(', ', $this->metastrings);
mysql_query("DELETE FROM {$CONFIG->dbprefix}metastrings WHERE id IN ($strings)");
}