From: eileen Date: Thu, 6 Jun 2013 05:29:12 +0000 (+1200) Subject: locblock test fix broken as it was 'taking advantage of' inconsistency in return... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=82adafa2621a03556f080a7072e05d60961d6f29;p=civicrm-core.git locblock test fix broken as it was 'taking advantage of' inconsistency in return param --- diff --git a/api/v3/LocBlock.php b/api/v3/LocBlock.php index 1727080523..85b4f2822d 100644 --- a/api/v3/LocBlock.php +++ b/api/v3/LocBlock.php @@ -101,6 +101,7 @@ function civicrm_api3_loc_block_get($params) { // If a return param has been set then fetch the appropriate fk objects // This is a helper because api chaining does not work with a key like 'email_2' if (!empty($options['return'])) { + unset($params['return']); $values = array(); $items = array('address', 'email', 'phone', 'im'); $returnAll = !empty($options['return']['all']); diff --git a/api/v3/examples/LocBlockCreate.php b/api/v3/examples/LocBlockCreate.php index 584520ce63..2ce3383b19 100644 --- a/api/v3/examples/LocBlockCreate.php +++ b/api/v3/examples/LocBlockCreate.php @@ -4,7 +4,7 @@ */ function loc_block_create_example(){ -$params = array( +$params = array( 'version' => 3, 'address_id' => 2, 'phone_id' => 2, @@ -21,13 +21,13 @@ $params = array( */ function loc_block_create_expectedresult(){ - $expectedResult = array( + $expectedResult = array( 'is_error' => 0, 'version' => 3, 'count' => 1, 'id' => 2, - 'values' => array( - '2' => array( + 'values' => array( + '2' => array( 'id' => '2', 'address_id' => '2', 'email_id' => '3', diff --git a/api/v3/examples/LocBlockCreateEntities.php b/api/v3/examples/LocBlockCreateEntities.php index b5eded8c90..545e64b2f1 100644 --- a/api/v3/examples/LocBlockCreateEntities.php +++ b/api/v3/examples/LocBlockCreateEntities.php @@ -4,21 +4,21 @@ Create entities and location block in 1 api call */ function loc_block_createentities_example(){ -$params = array( +$params = array( 'version' => 3, - 'email' => array( + 'email' => array( 'location_type_id' => 1, 'email' => 'test2@loc.block', ), - 'phone' => array( + 'phone' => array( 'location_type_id' => 1, 'phone' => '987654321', ), - 'phone_2' => array( + 'phone_2' => array( 'location_type_id' => 1, 'phone' => '456-7890', ), - 'address' => array( + 'address' => array( 'location_type_id' => 1, 'street_address' => '987654321', ), @@ -34,14 +34,14 @@ $params = array( */ function loc_block_createentities_expectedresult(){ - $expectedResult = array( + $expectedResult = array( 'is_error' => 0, 'version' => 3, 'count' => 1, 'id' => 3, - 'values' => array( - '3' => array( - 'address' => array( + 'values' => array( + '3' => array( + 'address' => array( 'id' => '3', 'location_type_id' => '1', 'is_primary' => 0, @@ -49,7 +49,7 @@ function loc_block_createentities_expectedresult(){ 'street_address' => '987654321', 'manual_geo_code' => 0, ), - 'email' => array( + 'email' => array( 'id' => '4', 'contact_id' => 'null', 'location_type_id' => '1', @@ -63,7 +63,7 @@ function loc_block_createentities_expectedresult(){ 'signature_text' => '', 'signature_html' => '', ), - 'phone' => array( + 'phone' => array( 'id' => '3', 'contact_id' => 'null', 'location_type_id' => '1', @@ -75,7 +75,7 @@ function loc_block_createentities_expectedresult(){ 'phone_numeric' => '', 'phone_type_id' => '', ), - 'phone_2' => array( + 'phone_2' => array( 'id' => '4', 'contact_id' => 'null', 'location_type_id' => '1', diff --git a/api/v3/examples/LocBlockGet.php b/api/v3/examples/LocBlockGet.php index 5e1d4cb289..86e7d42ab7 100644 --- a/api/v3/examples/LocBlockGet.php +++ b/api/v3/examples/LocBlockGet.php @@ -4,7 +4,7 @@ Get entities and location block in 1 api call */ function loc_block_get_example(){ -$params = array( +$params = array( 'version' => 3, 'id' => 3, 'return' => 'all', @@ -20,13 +20,13 @@ $params = array( */ function loc_block_get_expectedresult(){ - $expectedResult = array( + $expectedResult = array( 'id' => '3', 'address_id' => '3', 'email_id' => '4', 'phone_id' => '3', 'phone_2_id' => '4', - 'address' => array( + 'address' => array( 'id' => '3', 'location_type_id' => '1', 'is_primary' => 0, @@ -34,7 +34,7 @@ function loc_block_get_expectedresult(){ 'street_address' => '987654321', 'manual_geo_code' => 0, ), - 'email' => array( + 'email' => array( 'id' => '4', 'location_type_id' => '1', 'email' => 'test2@loc.block', @@ -43,7 +43,7 @@ function loc_block_get_expectedresult(){ 'on_hold' => 0, 'is_bulkmail' => 0, ), - 'phone' => array( + 'phone' => array( 'id' => '3', 'location_type_id' => '1', 'is_primary' => 0, @@ -51,7 +51,7 @@ function loc_block_get_expectedresult(){ 'phone' => '987654321', 'phone_numeric' => '987654321', ), - 'phone_2' => array( + 'phone_2' => array( 'id' => '4', 'location_type_id' => '1', 'is_primary' => 0, diff --git a/tests/phpunit/api/v3/LocBlockTest.php b/tests/phpunit/api/v3/LocBlockTest.php index f5c80b0792..8464feb03a 100644 --- a/tests/phpunit/api/v3/LocBlockTest.php +++ b/tests/phpunit/api/v3/LocBlockTest.php @@ -99,7 +99,11 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); // Now check our results using the return param 'all' - $getParams = array('version' => $this->_apiversion, 'id' => $id, 'return' => 'all'); + $getParams = array( + 'version' => $this->_apiversion, + 'id' => $id, + 'return' => 'all' + ); $result = civicrm_api($this->_entity, 'getsingle', $getParams); $this->documentMe($getParams, $result, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', NULL, 'get'); $this->assertNotNull($result['email_id'], 'In line ' . __LINE__);