);
}
+ /**
+ * Restore the DB for the next test.
+ *
+ * @throws \Exception
+ */
public function tearDown() {
// truncate a few tables
$tablesToTruncate = array(
$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__);
}
}
+ /**
+ * Test group filter syntaxes.
+ */
public function testGetGroupIDFromContact() {
$groupId = $this->groupCreate();
$description = "Get all from group and display contacts.";
* 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'));
}
}
+ /**
+ * Test creating multiple phones using chaining.
+ *
+ * @throws \Exception
+ */
public function testCRM13252MultipleChainedPhones() {
$contactID = $this->householdCreate();
$this->callAPISuccessGetCount('phone', array('contact_id' => $contactID), 0);
}
/**
- * 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',
// 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__);
}
/**
- * 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
*/
$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";
$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);
$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);
}
$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);
}
/**
'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);
}
/**
$this->assertTrue(!isset($refCountsIdx['sql:civicrm_address:contact_id']));
}
+ /**
+ * Test the use of sql operators.
+ */
public function testSQLOperatorsOnContactAPI() {
$this->individualCreate();
$this->organizationCreate();
}
/**
- * 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());