From ccb5a69319a6a367988534296c678c8abf322879 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 17 Feb 2010 15:32:23 +0000 Subject: Fixes #1526: Big honking warning added to unit tests. Getter test also deletes its subtypes now. git-svn-id: http://code.elgg.org/elgg/trunk@3945 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/tests/api/entity_getter_functions.php | 110 +++++++++++++++------------ 1 file changed, 62 insertions(+), 48 deletions(-) (limited to 'engine') diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index d09f1066d..f3f892d79 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -68,10 +68,25 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { * Called after each test method. */ public function tearDown() { - //$this->swallowErrors(); + global $CONFIG; + + $this->swallowErrors(); foreach ($this->entities as $e) { $e->delete(); } + + // manually remove subtype entries since there is no way + // to using the API. + $subtype_arr = array(); + foreach ($this->subtypes as $type => $subtypes) { + foreach ($subtypes as $subtype) { + $subtype_arr[] = "'$subtype'"; + } + } + + $subtype_str = implode(',', $subtype_arr); + $q = "DELETE FROM {$CONFIG->dbprefix}entity_subtypes WHERE subtype IN ($subtype_str)"; + delete_data($q); } /** @@ -107,7 +122,6 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { return $r; } - /** * Get a random valid subtype (that we just created) * @@ -225,16 +239,16 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $options = array( 'type' => $type, 'group_by' => 'e.type' - ); + ); - $es = elgg_get_entities($options); - $this->assertIsA($es, 'array'); + $es = elgg_get_entities($options); + $this->assertIsA($es, 'array'); - // should only ever return one object because of group by - $this->assertIdentical(count($es), 1); - foreach ($es as $e) { - $this->assertTrue(in_array($e->getType(), $type_arr)); - } + // should only ever return one object because of group by + $this->assertIdentical(count($es), 1); + foreach ($es as $e) { + $this->assertTrue(in_array($e->getType(), $type_arr)); + } } public function testElggAPIGettersValidTypeUsingTypesAsString() { @@ -243,16 +257,16 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $options = array( 'types' => $type, 'group_by' => 'e.type' - ); + ); - $es = elgg_get_entities($options); - $this->assertIsA($es, 'array'); + $es = elgg_get_entities($options); + $this->assertIsA($es, 'array'); - // should only ever return one object because of group by - $this->assertIdentical(count($es), 1); - foreach ($es as $e) { - $this->assertTrue(in_array($e->getType(), $type_arr)); - } + // should only ever return one object because of group by + $this->assertIdentical(count($es), 1); + foreach ($es as $e) { + $this->assertTrue(in_array($e->getType(), $type_arr)); + } } public function testElggAPIGettersValidTypeUsingTypesAsArray() { @@ -261,16 +275,16 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $options = array( 'types' => $type_arr, 'group_by' => 'e.type' - ); + ); - $es = elgg_get_entities($options); - $this->assertIsA($es, 'array'); + $es = elgg_get_entities($options); + $this->assertIsA($es, 'array'); - // should only ever return one object because of group by - $this->assertIdentical(count($es), 1); - foreach ($es as $e) { - $this->assertTrue(in_array($e->getType(), $type_arr)); - } + // should only ever return one object because of group by + $this->assertIdentical(count($es), 1); + foreach ($es as $e) { + $this->assertTrue(in_array($e->getType(), $type_arr)); + } } public function testElggAPIGettersValidTypeUsingTypesAsArrayPlural() { @@ -279,17 +293,17 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $options = array( 'types' => $types, 'group_by' => 'e.type' - ); + ); - $es = elgg_get_entities($options); - $this->assertIsA($es, 'array'); + $es = elgg_get_entities($options); + $this->assertIsA($es, 'array'); - // one of object and one of group - $this->assertIdentical(count($es), $num); + // one of object and one of group + $this->assertIdentical(count($es), $num); - foreach ($es as $e) { - $this->assertTrue(in_array($e->getType(), $types)); - } + foreach ($es as $e) { + $this->assertTrue(in_array($e->getType(), $types)); + } } @@ -309,14 +323,14 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $options = array( 'types' => array($invalid, $valid), 'group_by' => 'e.type' - ); + ); - $es = elgg_get_entities($options); - $this->assertIsA($es, 'array'); + $es = elgg_get_entities($options); + $this->assertIsA($es, 'array'); - // should only ever return one object because of group by - $this->assertIdentical(count($es), 1); - $this->assertIdentical($es[0]->getType(), $valid); + // should only ever return one object because of group by + $this->assertIdentical(count($es), 1); + $this->assertIdentical($es[0]->getType(), $valid); } public function testElggAPIGettersValidAndInvalidTypesPlural() { @@ -338,16 +352,16 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $options = array( 'types' => $types, 'group_by' => 'e.type' - ); + ); - $es = elgg_get_entities($options); - $this->assertIsA($es, 'array'); + $es = elgg_get_entities($options); + $this->assertIsA($es, 'array'); - // should only ever return one object because of group by - $this->assertIdentical(count($es), $valid_num); - foreach ($es as $e) { - $this->assertTrue(in_array($e->getType(), $valid)); - } + // should only ever return one object because of group by + $this->assertIdentical(count($es), $valid_num); + foreach ($es as $e) { + $this->assertTrue(in_array($e->getType(), $valid)); + } } -- cgit v1.2.3