aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-17 15:32:23 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-17 15:32:23 +0000
commitccb5a69319a6a367988534296c678c8abf322879 (patch)
tree39e16ed3a8f4c70e68cd6bc9ac76b49d177d5ad8 /engine
parent287ea7790c170e4f5c13c721e759f1a37ed5ef02 (diff)
downloadelgg-ccb5a69319a6a367988534296c678c8abf322879.tar.gz
elgg-ccb5a69319a6a367988534296c678c8abf322879.tar.bz2
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
Diffstat (limited to 'engine')
-rw-r--r--engine/tests/api/entity_getter_functions.php110
1 files changed, 62 insertions, 48 deletions
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));
+ }
}