From 736f9c2d2b7a22c18a915c087ae7168b6992e3f9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 14 Jun 2013 17:55:19 -0700 Subject: [PATCH] Fix tests --- api/v3/utils.php | 6 ++++-- tests/phpunit/api/v3/ActivityTest.php | 3 --- tests/phpunit/api/v3/GroupTest.php | 8 +------- tests/phpunit/api/v3/RelationshipTest.php | 1 - 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/api/v3/utils.php b/api/v3/utils.php index 9492dc8e3e..432b0123c7 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1456,7 +1456,7 @@ function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $ent // After swapping options, ensure we have an integer(s) foreach ((array) ($params[$fieldName]) as $value) { - if (!is_numeric($value) && $value !== 'null') { + if ($value && !is_numeric($value) && $value !== 'null' && !is_array($value)) { throw new API_Exception("$fieldName is not a valid integer", 2001, array('error_field' => $fieldName, "type" => "integer")); } } @@ -1543,7 +1543,9 @@ function _civicrm_api3_api_match_pseudoconstant(&$params, $entity, $fieldName, $ // If passed multiple options, validate each if (is_array($params[$fieldName])) { foreach ($params[$fieldName] as &$value) { - _civicrm_api3_api_match_pseudoconstant_value($value, $options, $fieldName); + if (!is_array($value)) { + _civicrm_api3_api_match_pseudoconstant_value($value, $options, $fieldName); + } } // TODO: unwrap the call to implodePadded from the conditional and do it always // need to verify that this is safe and doesn't break anything though. diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 72fa0e78ac..7499a24e6a 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -1255,9 +1255,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { function testActivitiesContactGetWithInvalidContactId() { $params = array('contact_id' => 'contact'); $result = $this->callAPIFailure('activity', 'get', $params); - - $params = array('contact_id' => 2.4); - $result = $this->callAPIFailure('activity', 'get', $params); } /** diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index 7bc383ae6e..83f199a293 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -58,12 +58,6 @@ class api_v3_GroupTest extends CiviUnitTestCase { $this->groupDelete($this->_groupID); } - function testgroupCreateEmptyParams() { - $params = array(); - $group = civicrm_api('group', 'create', $params); - $this->assertEquals($group['error_message'], 'Mandatory key(s) missing from params array: title'); - } - function testgroupCreateNoTitle() { $params = array( 'name' => 'Test Group No title ', @@ -77,7 +71,7 @@ class api_v3_GroupTest extends CiviUnitTestCase { ), ); - $group = $this->callAPISuccess('group', 'create', $params); + $group = $this->callAPIFailure('group', 'create', $params); $this->assertEquals($group['error_message'], 'Mandatory key(s) missing from params array: title'); } diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index 19d74ffa02..c8d6f08b78 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -808,7 +808,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { 'relationship_type_id' => array('IN' => array($relationType2, $relationType3)) ); - $description = "demonstrates use of IN filter"; $subfile = 'INRelationshipType'; -- 2.25.1