From 69f028bcc13c19cfc3c90158fbc98b9acf4b1953 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 3 Feb 2014 15:56:25 -0800 Subject: [PATCH] Test cleanup --- .../createEntities.php} | 10 +-- .../getEntities.php} | 82 ++++++++++--------- .../simpleCreate.php} | 2 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 5 ++ tests/phpunit/api/v3/LocBlockTest.php | 14 ++-- 5 files changed, 65 insertions(+), 48 deletions(-) rename api/v3/examples/{LocBlockCreateEntities.php => LocBlock/createEntities.php} (92%) rename api/v3/examples/{LocBlockGet.php => LocBlock/getEntities.php} (52%) rename api/v3/examples/{LocBlockCreate.php => LocBlock/simpleCreate.php} (97%) diff --git a/api/v3/examples/LocBlockCreateEntities.php b/api/v3/examples/LocBlock/createEntities.php similarity index 92% rename from api/v3/examples/LocBlockCreateEntities.php rename to api/v3/examples/LocBlock/createEntities.php index dad0145a10..a19667aa6b 100644 --- a/api/v3/examples/LocBlockCreateEntities.php +++ b/api/v3/examples/LocBlock/createEntities.php @@ -1,9 +1,9 @@ array( 'location_type_id' => 1, @@ -24,7 +24,7 @@ $params = array( ); try{ - $result = civicrm_api3('loc_block', 'createEntities', $params); + $result = civicrm_api3('loc_block', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // handle error here @@ -40,7 +40,7 @@ return $result; /** * Function returns array of result expected from previous function */ -function loc_block_createentities_expectedresult(){ +function loc_block_create_expectedresult(){ $expectedResult = array( 'is_error' => 0, diff --git a/api/v3/examples/LocBlockGet.php b/api/v3/examples/LocBlock/getEntities.php similarity index 52% rename from api/v3/examples/LocBlockGet.php rename to api/v3/examples/LocBlock/getEntities.php index ec9c0375fc..9043e8c57a 100644 --- a/api/v3/examples/LocBlockGet.php +++ b/api/v3/examples/LocBlock/getEntities.php @@ -29,43 +29,51 @@ return $result; function loc_block_get_expectedresult(){ $expectedResult = array( - 'id' => '3', - 'address_id' => '3', - 'email_id' => '4', - 'phone_id' => '3', - 'phone_2_id' => '4', - 'address' => array( - 'id' => '3', - 'location_type_id' => '1', - 'is_primary' => 0, - 'is_billing' => 0, - 'street_address' => '987654321', - 'manual_geo_code' => 0, - ), - 'email' => array( - 'id' => '4', - 'location_type_id' => '1', - 'email' => 'test2@loc.block', - 'is_primary' => 0, - 'is_billing' => 0, - 'on_hold' => 0, - 'is_bulkmail' => 0, - ), - 'phone' => array( - 'id' => '3', - 'location_type_id' => '1', - 'is_primary' => 0, - 'is_billing' => 0, - 'phone' => '987654321', - 'phone_numeric' => '987654321', - ), - 'phone_2' => array( - 'id' => '4', - 'location_type_id' => '1', - 'is_primary' => 0, - 'is_billing' => 0, - 'phone' => '456-7890', - 'phone_numeric' => '4567890', + 'is_error' => 0, + 'version' => 3, + 'count' => 1, + 'id' => 3, + 'values' => array( + '3' => array( + 'id' => '3', + 'address_id' => '3', + 'email_id' => '4', + 'phone_id' => '3', + 'phone_2_id' => '4', + 'address' => array( + 'id' => '3', + 'location_type_id' => '1', + 'is_primary' => 0, + 'is_billing' => 0, + 'street_address' => '987654321', + 'manual_geo_code' => 0, + ), + 'email' => array( + 'id' => '4', + 'location_type_id' => '1', + 'email' => 'test2@loc.block', + 'is_primary' => 0, + 'is_billing' => 0, + 'on_hold' => 0, + 'is_bulkmail' => 0, + ), + 'phone' => array( + 'id' => '3', + 'location_type_id' => '1', + 'is_primary' => 0, + 'is_billing' => 0, + 'phone' => '987654321', + 'phone_numeric' => '987654321', + ), + 'phone_2' => array( + 'id' => '4', + 'location_type_id' => '1', + 'is_primary' => 0, + 'is_billing' => 0, + 'phone' => '456-7890', + 'phone_numeric' => '4567890', + ), + ), ), ); diff --git a/api/v3/examples/LocBlockCreate.php b/api/v3/examples/LocBlock/simpleCreate.php similarity index 97% rename from api/v3/examples/LocBlockCreate.php rename to api/v3/examples/LocBlock/simpleCreate.php index 7f893f4d35..a681afb6f6 100644 --- a/api/v3/examples/LocBlockCreate.php +++ b/api/v3/examples/LocBlock/simpleCreate.php @@ -1,7 +1,7 @@ _apiversion; diff --git a/tests/phpunit/api/v3/LocBlockTest.php b/tests/phpunit/api/v3/LocBlockTest.php index b44577123c..f33dc5212a 100644 --- a/tests/phpunit/api/v3/LocBlockTest.php +++ b/tests/phpunit/api/v3/LocBlockTest.php @@ -58,7 +58,8 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { 'phone_id' => $phone['id'], 'email_id' => $email['id'], ); - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); + $description = 'Create locBlock with existing entities'; + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'simpleCreate'); $id = $result['id']; $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertNotNull($result['values'][$id]['id'], 'In line ' . __LINE__); @@ -84,16 +85,19 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { 'street_address' => '987654321', ), ); - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, 'Create entities and location block in 1 api call', NULL, 'createEntities'); + $description = "Create entities and locBlock in 1 api call"; + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'createEntities'); $id = $result['id']; $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); // Now check our results using the return param 'all' - $getParams = array( 'id' => $id, - 'return' => 'all' + $getParams = array( + 'id' => $id, + 'return' => 'all', ); // Can't use callAPISuccess with getsingle - $result = $this->callAPIAndDocument($this->_entity, 'getsingle', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', NULL, 'get'); + $result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', 'getEntities', 'get'); + $result = array_pop($result['values']); $this->assertNotNull($result['email_id'], 'In line ' . __LINE__); $this->assertNotNull($result['phone_id'], 'In line ' . __LINE__); $this->assertNotNull($result['phone_2_id'], 'In line ' . __LINE__); -- 2.25.1