From 678bb176b6a17c78baf31cc983aff5f73d959f43 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Wed, 2 Sep 2015 13:10:51 +1200 Subject: [PATCH] CRM-17120 remove call to uncached getLabel function --- api/v3/Domain.php | 16 +++++++--------- tests/phpunit/api/v3/DomainTest.php | 17 ++++++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/api/v3/Domain.php b/api/v3/Domain.php index 49a8289746..76bceed8e9 100644 --- a/api/v3/Domain.php +++ b/api/v3/Domain.php @@ -63,7 +63,6 @@ function civicrm_api3_domain_get($params) { 'contact_id' => $domain['contact_id'], ); $values['location'] = CRM_Core_BAO_Location::getValues($locparams, TRUE); - $address_array = array( 'street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id', @@ -76,16 +75,15 @@ function civicrm_api3_domain_get($params) { if (!empty($values['location']['phone'])) { $domain['domain_phone'] = array( - 'phone_type' => CRM_Core_OptionGroup::getLabel( - 'phone_type', - CRM_Utils_Array::value( - 'phone_type_id', - $values['location']['phone'][1] - ) + 'phone_type' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', + CRM_Utils_Array::value( + 'phone_type_id', + $values['location']['phone'][1] + ) ), 'phone' => CRM_Utils_Array::value( - 'phone', - $values['location']['phone'][1] + 'phone', + $values['location']['phone'][1] ), ); } diff --git a/tests/phpunit/api/v3/DomainTest.php b/tests/phpunit/api/v3/DomainTest.php index a13be7966b..ad23eacb5c 100644 --- a/tests/phpunit/api/v3/DomainTest.php +++ b/tests/phpunit/api/v3/DomainTest.php @@ -38,7 +38,6 @@ class api_v3_DomainTest extends CiviUnitTestCase { /* This test case doesn't require DB reset - apart from where cleanDB() is called. */ - public $DBResetRequired = FALSE; protected $_apiversion = 3; @@ -56,9 +55,7 @@ class api_v3_DomainTest extends CiviUnitTestCase { // taken from form code - couldn't find good method to use $params['entity_id'] = 1; $params['entity_table'] = CRM_Core_BAO_Domain::getTableName(); - $domain = 1; $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); - $location = array(); $domContact = $this->callAPISuccess('contact', 'create', array( 'contact_type' => 'Organization', 'organization_name' => 'new org', @@ -112,10 +109,16 @@ class api_v3_DomainTest extends CiviUnitTestCase { $this->assertArrayHasKey('id', $domain); $this->assertArrayHasKey('name', $domain); $this->assertArrayHasKey('domain_email', $domain); - $this->assertArrayHasKey('domain_phone', $domain); + $this->assertEquals(array( + 'phone_type' => 'Phone', + 'phone' => '456-456', + ), $domain['domain_phone']); $this->assertArrayHasKey('domain_address', $domain); } + /** + * Test get function with current domain. + */ public function testGetCurrentDomain() { $params = array('current_domain' => 1); $result = $this->callAPISuccess('domain', 'get', $params); @@ -143,10 +146,10 @@ class api_v3_DomainTest extends CiviUnitTestCase { } } - ///////////////// civicrm_domain_create methods - /** - * This test checks for a memory leak observed when doing 2 gets on current domain + * This test checks for a memory leak. + * + * The leak was observed when doing 2 gets on current domain. */ public function testGetCurrentDomainTwice() { $domain = $this->callAPISuccess('domain', 'getvalue', array( -- 2.25.1