From 5d3b3d60ce01f33581f4e8114ca9e17cbc39109d Mon Sep 17 00:00:00 2001 From: Coleman Watts <coleman@civicrm.org> Date: Sun, 28 Jul 2013 21:18:59 -0700 Subject: [PATCH] Test fix --- CRM/Core/DAO.php | 11 ++++++----- tests/phpunit/api/v3/ACLPermissionTest.php | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 9fbd3900ac..bbf4eebc87 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1317,10 +1317,12 @@ SELECT contact_id continue; } // Pick an option value if needed - $options = $daoName::buildOptions($dbName); - if ($options) { - $object->$dbName = key($options); - continue; + if ($value['type'] !== CRM_Utils_Type::T_BOOL) { + $options = $daoName::buildOptions($dbName, 'create'); + if ($options) { + $object->$dbName = key($options); + continue; + } } switch ($value['type']) { @@ -1331,7 +1333,6 @@ SELECT contact_id break; case CRM_Utils_Type::T_BOOL: - case CRM_Utils_Type::T_BOOLEAN: if (isset($value['default'])) { $object->$dbName = $value['default']; } diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index a7b9c287b9..d9e07c4898 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -67,7 +67,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { unset($config->userPermissionClass->permissions); } /** - * Function just tests that an empty where hook returns the 2 expected results + * Function tests that an empty where hook returns no results */ function testContactGetNoResultsHook(){ $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults')); @@ -91,10 +91,10 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { $this->assertEquals(2, $result['count']); } /** - * Function just tests that an empty where hook returns the 2 expected results + * Function tests that deleted contacts are not returned */ function testContactGetPermissionHookNoDeleted(){ - $this->callAPISuccess('contact', 'create', array('id' => 2, 'is_deleted' => 1)); + $result = $this->callAPISuccess('contact', 'create', array('id' => 2, 'is_deleted' => 1));print "\n";print_r($result); $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookAllResults')); $result = $this->callAPISuccess('contact', 'get', array( 'check_permissions' => 1, -- GitLab