From 701a69dad6b25455ac5041bac3119aa85175acbe Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Fri, 11 Sep 2015 19:23:30 +1200 Subject: [PATCH] comment fixes --- tests/phpunit/api/v3/ContactTest.php | 54 ++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index d3023fc541..e8660cc92e 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -68,6 +68,11 @@ class api_v3_ContactTest extends CiviUnitTestCase { ); } + /** + * Restore the DB for the next test. + * + * @throws \Exception + */ public function tearDown() { // truncate a few tables $tablesToTruncate = array( @@ -440,7 +445,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertNotNull($customFldDate, 'in line ' . __LINE__); $this->assertEquals($dateTime, $customFldDate); $this->assertEquals(000000, $customFldTime); - $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__); + $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__); } @@ -795,6 +800,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { } + /** + * Test group filter syntaxes. + */ public function testGetGroupIDFromContact() { $groupId = $this->groupCreate(); $description = "Get all from group and display contacts."; @@ -1571,7 +1579,11 @@ class api_v3_ContactTest extends CiviUnitTestCase { * Test to check return works OK. */ public function testContactGetReturnValues() { - $extraParams = array('nick_name' => 'Bob', 'phone' => '456', 'email' => 'e@mail.com'); + $extraParams = array( + 'nick_name' => 'Bob', + 'phone' => '456', + 'email' => 'e@mail.com', + ); $contactID = $this->individualCreate($extraParams); //actually it turns out the above doesn't create a phone $this->callAPISuccess('phone', 'create', array('contact_id' => $contactID, 'phone' => '456')); @@ -1589,6 +1601,11 @@ class api_v3_ContactTest extends CiviUnitTestCase { } } + /** + * Test creating multiple phones using chaining. + * + * @throws \Exception + */ public function testCRM13252MultipleChainedPhones() { $contactID = $this->householdCreate(); $this->callAPISuccessGetCount('phone', array('contact_id' => $contactID), 0); @@ -1634,15 +1651,14 @@ class api_v3_ContactTest extends CiviUnitTestCase { } /** - * Verify attempt to create individual with chained arrays and sequential + * Verify attempt to create individual with chained arrays and sequential. */ public function testGetIndividualWithChainedArraysAndSequential() { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); $params['custom_' . $ids['custom_field_id']] = "custom string"; - $moreids = $this->CustomGroupMultipleCreateWithFields(); - $description = "/*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created "; - $subfile = "APIChainedArray"; + $moreIDs = $this->CustomGroupMultipleCreateWithFields(); + $params = array( 'sequential' => 1, 'first_name' => 'abc3', @@ -1664,14 +1680,14 @@ class api_v3_ContactTest extends CiviUnitTestCase { // delete the contact and custom groups $this->callAPISuccess('contact', 'delete', array('id' => $result['id'])); $this->customGroupDelete($ids['custom_group_id']); - $this->customGroupDelete($moreids['custom_group_id']); + $this->customGroupDelete($moreIDs['custom_group_id']); $this->assertEquals($result['id'], $result['values'][0]['id']); $this->assertArrayKeyExists('api.website.create', $result['values'][0]); } /** - * Verify attempt to create individual with chained arrays + * Verify attempt to create individual with chained arrays. */ public function testGetIndividualWithChainedArrays() { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); @@ -1739,7 +1755,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { } /** - * Verify attempt to create individual with chained arrays and sequential. + * Verify attempt to create individual with chained arrays and sequential. * * See https://issues.civicrm.org/jira/browse/CRM-15815 */ @@ -1779,6 +1795,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals(1, $result['values'][0]['api.website.get']['count']); } + /** + * Test retrieving an individual with chained array syntax. + */ public function testGetIndividualWithChainedArraysFormats() { $description = "This demonstrates the usage of chained api functions.\nIn this case no notes or custom fields have been created."; $subfile = "APIChainedArrayFormats"; @@ -1931,7 +1950,11 @@ class api_v3_ContactTest extends CiviUnitTestCase { $params = array( 'display_name' => 'batman', 'contact_type' => 'Individual', - 'api.tag.create' => array('name' => '$value.id', 'description' => '$value.display_name', 'format.only_id' => 1), + 'api.tag.create' => array( + 'name' => '$value.id', + 'description' => '$value.display_name', + 'format.only_id' => 1, + ), 'api.entity_tag.create' => array('tag_id' => '$value.api.tag.create'), ); $result = $this->callAPIAndDocument('Contact', 'Create', $params, __FUNCTION__, __FILE__, $description, $subfile); @@ -1998,7 +2021,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { $subfile = "GetCountContact"; $params = array('id' => 17); $result = $this->callAPIAndDocument('Contact', 'GetCount', $params, __FUNCTION__, __FILE__, $description, - $subfile, 'getcount'); + $subfile); $this->assertEquals('1', $result); $this->callAPISuccess('Contact', 'Delete', $params); } @@ -2049,7 +2072,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals('API permission check failed for Contact/create call; insufficient permission: require access CiviCRM and add contacts', $result['error_message'], 'lacking permissions should not be enough to create a contact'); $config->userPermissionClass->permissions = array('access CiviCRM', 'add contacts', 'import contacts'); - $this->callAPISuccess('contact', 'create', $params, NULL, 'overfluous permissions should be enough to create a contact'); + $this->callAPISuccess('contact', 'create', $params); } /** @@ -2082,7 +2105,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { 'edit all contacts', 'import contacts', ); - $this->callAPISuccess('contact', 'update', $params, NULL, 'overfluous permissions should be enough to update a contact'); + $this->callAPISuccess('contact', 'update', $params); } /** @@ -2204,6 +2227,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertTrue(!isset($refCountsIdx['sql:civicrm_address:contact_id'])); } + /** + * Test the use of sql operators. + */ public function testSQLOperatorsOnContactAPI() { $this->individualCreate(); $this->organizationCreate(); @@ -2270,7 +2296,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { } /** - * CRM-15443 - ensure getlist api does not return deleted contacts + * CRM-15443 - ensure getlist api does not return deleted contacts. */ public function testGetlistExcludeConditions() { $name = md5(time()); -- 2.25.1