aboutsummaryrefslogtreecommitdiff
path: root/engine/tests
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-27 16:56:12 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-27 16:56:12 +0000
commit553d34a3127d34c5bbfde77c1e09326017c13101 (patch)
treeb8553d407be8e2229dc0c4b385dff927fb7e0918 /engine/tests
parentd3b126e434daf2357be1b4bf20a0f002dac328fc (diff)
downloadelgg-553d34a3127d34c5bbfde77c1e09326017c13101.tar.gz
elgg-553d34a3127d34c5bbfde77c1e09326017c13101.tar.bz2
Fixed caching issue that caused metadata test for get_entities_from_metadata() to fail.
git-svn-id: http://code.elgg.org/elgg/trunk@3588 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/tests')
-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)");
}