function setUp() {
parent::setUp();
- $this->_contributionTypeID = $this->contributionTypeCreate();
+ $this->_financialTypeID = 1;
}
function tearDown() {
- $this->contributionTypeDelete();
}
/**
$params = array(
'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
'title' => 'Test Contribution Page',
- 'financial_type_id' => $this->_contributionTypeID,
+ 'financial_type_id' => $this->_financialTypeID,
'intro_text' => '',
'footer_text' => 'Thanks',
'is_for_organization' => 0,
$params = array(
'title' => 'Test Contribution Page',
- 'financial_type_id' => $this->_contributionTypeID,
+ 'financial_type_id' => $this->_financialTypeID,
'is_active' => 1,
);
$params = array(
'title' => 'Test Contribution Page',
- 'financial_type_id' => $this->_contributionTypeID,
+ 'financial_type_id' => $this->_financialTypeID,
'is_active' => 1,
);
$setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, $values);
$this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
- $this->assertEquals($this->_contributionTypeID, $values['financial_type_id'], 'Verify financial types id.');
+ $this->assertEquals($this->_financialTypeID, $values['financial_type_id'], 'Verify financial types id.');
$this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
ContributionPage::delete($contributionpage->id);
}
$params = array(
'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
'title' => 'Test Contribution Page',
- 'financial_type_id' => $this->_contributionTypeID,
+ 'financial_type_id' => $this->_financialTypeID,
'intro_text' => '',
'footer_text' => 'Thanks',
'is_for_organization' => 0,
$contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
$copycontributionpage = CRM_Contribute_BAO_ContributionPage::copy($contributionpage->id);
- $this->assertEquals($copycontributionpage->financial_type_id, $this->_contributionTypeID, 'Check for Financial type id.');
+ $this->assertEquals($copycontributionpage->financial_type_id, $this->_financialTypeID, 'Check for Financial type id.');
$this->assertEquals($copycontributionpage->goal_amount, 400, 'Check for goal amount.');
ContributionPage::delete($contributionpage->id);
ContributionPage::delete($copycontributionpage->id);
$paymentProcessor = PaypalPro::create();
$params = array(
'title' => 'Test Contribution Page',
- 'financial_type_id' => $this->_contributionTypeID,
+ 'financial_type_id' => $this->_financialTypeID,
'is_active' => 1,
'payment_processor_id' => $paymentProcessor,
);
function setUp() {
parent::setUp();
- $this->contributionTypeCreate();
}
function teardown() {
- $this->contributionTypeDelete();
}
/**
$params = array(
'contact_id' => $contactId,
'currency' => 'USD',
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'contribution_status_id' => 1,
'payment_instrument_id' => 1,
'source' => 'STUDENT',
$params = array(
'contact_id' => $contactId,
'currency' => 'USD',
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'contribution_status_id' => 1,
'payment_instrument_id' => 1,
'source' => 'STUDENT',
$param = array(
'contact_id' => $contactId,
'currency' => 'USD',
- 'financial_type_id' => 4,
+ 'financial_type_id' => 4,
'contribution_status_id' => 1,
'receive_date' => date('Ymd'),
'total_amount' => 66,
$param = array(
'contact_id' => $contactId,
'currency' => 'USD',
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'contribution_status_id' => 1,
'payment_instrument_id' => 1,
'source' => 'STUDENT',
$param = array(
'contact_id' => $contactId,
'currency' => 'USD',
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'contribution_status_id' => 1,
'payment_instrument_id' => 1,
'source' => 'STUDENT',
$param = array(
'contact_id' => $contactId,
'currency' => 'USD',
- 'financial_type_id' => 1,
+ 'financial_type_id' => 1,
'contribution_status_id' => 1,
'payment_instrument_id' => 1,
'source' => 'STUDENT',
*/
function testCreate() {
$contactId = $this->individualCreate();
- $contributionTypeId = $this->contributionTypeCreate();
- $contributionId = $this->contributionCreate($contactId, $contributionTypeId);
+ $financialTypeId = 1;
+ $contributionId = $this->contributionCreate($contactId, $financialTypeId);
$params = array(
- 'contribution_id' => $contributionTypeId,
+ 'contribution_id' => $financialTypeId,
'to_financial_account_id' => 1,
'trxn_date' => 20091021184930,
'trxn_type' => 'Debit',
);
$this->processor = new CRM_Core_Payment_AuthorizeNet('Contribute', $paymentProcessor);
- $this->_contributionTypeId = $this->contributionTypeCreate();
+ $this->_financialTypeId = 1;
// for some strange unknown reason, in batch mode this value gets set to null
// so crude hack here to avoid an exception and hence an error
function tearDown() {
$this->paymentProcessor->delete($this->processorParams->id);
- $tablesToTruncate = array( 'civicrm_financial_type', 'civicrm_contribution', 'civicrm_contribution_recur', 'civicrm_line_item' );
+ $tablesToTruncate = array('civicrm_contribution', 'civicrm_contribution_recur', 'civicrm_line_item' );
$this->quickCleanup($tablesToTruncate);
}
$nameParams = array('first_name' => $firstName, 'last_name' => $lastName);
$contactId = Contact::createIndividual($nameParams);
- $ids = array('contribution' => NULL);
$invoiceID = sha1(rand());
$amount = rand(100, 1000) . '.00';
$contributionParams = array(
'contact_id' => $contactId,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'receive_date' => date('Ymd'),
'total_amount' => $amount,
'invoice_id' => $invoiceID,
'frequency_interval' => 1,
'frequency_unit' => 'month',
'installments' => 12,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'is_email_receipt' => 1,
'from_email_address' => "{$firstName}.{$lastName}@example.com",
'receive_date' => date('Ymd'),
'email' => "{$firstName}.{$lastName}@example.com",
'contactID' => $contactId,
'contributionID' => $contribution->id,
- 'contributionTypeID' => $this->_contributionTypeId,
+ 'contributionTypeID' => $this->_financialTypeId,
'contributionRecurID' => $recur->id,
);
$contributionParams = array(
'contact_id' => $contactId,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'receive_date' => $start_date,
'total_amount' => $amount,
'invoice_id' => $invoiceID,
'is_test' => 1,
'contribution_status_id' => 2,
);
- $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams, $ids);
+
+ $this->callAPISuccess('contribution', 'create', $contributionParams);
$params = array(
'qfKey' => '00ed21c7ca00a1f7d555555596ef7_4454',
'frequency_interval' => 1,
'frequency_unit' => 'month',
'installments' => 3,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'is_email_receipt' => 1,
'from_email_address' => "{$firstName}.{$lastName}@example.com",
'receive_date' => $start_date,
'email' => "{$firstName}.{$lastName}@example.com",
'contactID' => $contactId,
'contributionID' => $contribution->id,
- 'contributionTypeID' => $this->_contributionTypeId,
+ 'contributionTypeID' => $this->_financialTypeId,
'contributionRecurID' => $recur->id,
);
);
$this->_relationshipTypeId = $this->relationshipTypeCreate($params);
$this->_orgContactID = $this->organizationCreate();
- $this->_contributionTypeId = $this->contributionTypeCreate();
+ $this->_financialTypeId = 1;
$params = array(
'name' => 'test type',
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'fixed',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
$this->relationshipTypeDelete($this->_relationshipTypeId);
$this->membershipTypeDelete(array('id' => $this->_membershipTypeID));
$this->membershipStatusDelete($this->_mebershipStatusID);
- $this->contributionTypeDelete(NULL);
$this->contactDelete($this->_orgContactID);
}
$this->_relationshipTypeId = $this->relationshipTypeCreate($params);
$this->_orgContactID = $this->organizationCreate();
$this->_indiviContactID = $this->individualCreate();
- $this->_contributionTypeId = $this->contributionTypeCreate();
+ $this->_financialTypeId = 1;
$this->_membershipStatusID = $this->membershipStatusCreate('test status');
}
function tearDown() {
$this->relationshipTypeDelete($this->_relationshipTypeId);
$this->membershipStatusDelete($this->_membershipStatusID);
- $this->contributionTypeDelete();
$this->contactDelete($this->_orgContactID);
$this->contactDelete($this->_indiviContactID);
}
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'fixed',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
);
'period_type' => 'fixed',
'member_of_contact_id' => $this->_orgContactID,
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
);
'period_type' => 'fixed',
'duration_interval' => 1,
'member_of_contact_id' => $this->_orgContactID,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'period_type' => 'fixed',
'member_of_contact_id' => $this->_orgContactID,
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'fixed_period_start_day' => 1213,
'fixed_period_rollover_day' => 1214,
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'fixed',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'period_type' => 'fixed',
'member_of_contact_id' => $this->_orgContactID,
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'rolling',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'rolling',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'rolling',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
);
$this->_relationshipTypeId = $this->relationshipTypeCreate($params);
$this->_orgContactID = $this->organizationCreate();
- $this->_contributionTypeId = $this->contributionTypeCreate();
+ $this->_financialTypeId = 1;
$this->_membershipTypeName = 'Mickey Mouse Club Member';
$params = array(
'name' => $this->_membershipTypeName,
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'fixed',
'duration_interval' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'relationship_type_id' => $this->_relationshipTypeId,
'visibility' => 'Public',
'is_active' => 1,
$this->relationshipTypeDelete($this->_relationshipTypeId);
$this->membershipTypeDelete(array('id' => $this->_membershipTypeID));
$this->membershipStatusDelete($this->_mebershipStatusID);
- $this->contributionTypeDelete(NULL);
$this->contactDelete($this->_orgContactID);
}
);
$this->quickCleanup($tablesToTruncate);
- $this->contributionTypeDelete();
}
/**
* Test civicrm_contact_check_params with no contact type
return $contributionPage;
}
- /**
- * Function to create Financial Type
- *
- * @return int $id of financial account created
- */
- function contributionTypeCreate() {
-
- $op = new PHPUnit_Extensions_Database_Operation_Insert();
- $op->execute($this->_dbconn,
- new PHPUnit_Extensions_Database_DataSet_XMLDataSet(
- dirname(__FILE__) . '/../api/v' . API_LATEST_VERSION . '/dataset/financial_types.xml'
- )
- );
-
- $financialType = CRM_Contribute_PseudoConstant::financialType();
- CRM_Contribute_PseudoConstant::flush('financialType');
- return key($financialType);
- }
-
- /**
- * Function to delete financial Types
- * @param int $contributionTypeId
- */
- function contributionTypeDelete($contributionTypeID = NULL) {
- if ($contributionTypeID === NULL) {
- $this->callAPISuccess('Contribution', 'get',
- array(
- 'financial_type_id' => 10,
- 'api.contribution.delete' => 1,
- )
- );
- $this->callAPISuccess('Contribution', 'get',
- array(
- 'financial_type_id' => 11,
- 'api.contribution.delete' => 1,
- )
- );
-
- // we know those were loaded from /dataset/financial_types.xml
- $del = CRM_Financial_BAO_FinancialType::del(10, 1);
- $del = CRM_Financial_BAO_FinancialType::del(11, 1);
- }
- else {
- $this->callAPISuccess('Contribution', 'get', array(
- 'financial_type_id' => $contributionTypeID,
- 'api.contribution.delete' => 1
- ));
- $del = CRM_Financial_BAO_FinancialType::del($contributionTypeID, 1);
- }
- if (is_array($del)) {
- $this->assertEquals(0, CRM_Utils_Array::value('is_error', $del), $del['error_message']);
- }
- }
-
/**
* Function to create Tag
*
*/
class api_v3_ImTest extends CiviUnitTestCase {
- protected $_apiversion;
+ protected $_apiversion = 3;
protected $params;
protected $id;
protected $_entity;
parent::setUp();
$this->_entity = 'im';
- $this->_apiversion = 3;
$this->_contactID = $this->organizationCreate();
$this->params = array(
- 'version' => 3,
'contact_id' => $this->_contactID,
'name' => 'My Yahoo IM Handle',
'location_type_id' => 1,
}
public function testCreateIm() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->getAndCheck($this->params, $result['id'], $this->_entity);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
}
public function testGetIm() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $result = civicrm_api($this->_entity, 'get', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $result = $this->callAPIAndDocument($this->_entity, 'get', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
- civicrm_api($this->_entity, 'delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess($this->_entity, 'delete', array('id' => $result['id']));
}
public function testDeleteIm() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->assertAPISuccess($result, 'in line ' . __LINE__);
- $deleteParams = array('version' => 3, 'id' => $result['id']);
- $result = civicrm_api($this->_entity, 'delete', $deleteParams);
- $this->documentMe($deleteParams, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
- $checkDeleted = civicrm_api($this->_entity, 'get', array('version' => 3));
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $deleteParams = array('id' => $result['id']);
+ $result = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__);
+ $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array());
$this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__);
}
public function testDeleteImInvalid() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->assertAPISuccess($result, 'in line ' . __LINE__);
- $deleteParams = array('version' => 3, 'id' => 600);
- $result = civicrm_api($this->_entity, 'delete', $deleteParams);
- $this->assertEquals(1,$result['is_error'], 'In line ' . __LINE__);
- $checkDeleted = civicrm_api($this->_entity, 'get', array('version' => 3));
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $deleteParams = array('id' => 600);
+ $result = $this->callAPIFailure($this->_entity, 'delete', $deleteParams);
+ $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array());
$this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__);
}
}
* Test creation of a participant with an associated contribution
*/
function testCreateParticipantWithPayment() {
- $this->_contributionTypeId = $this->contributionTypeCreate();
+ $this->_financialTypeId = 1;
$description = "single function to create contact w partipation & contribution. Note that in the
case of 'contribution' the 'create' is implied (api.contribution.create)";
$subfile = "CreateParticipantPayment";
<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
protected $_ufGroupId = 11;
protected $_ufFieldId;
protected $_contactId = 69;
- protected $_apiversion;
+ protected $_apiversion = 3;
protected $_params;
protected $_entity = 'uf_field';
public $_eNoticeCompliant = TRUE;
)
);
- $this->_apiversion = 3;
$op = new PHPUnit_Extensions_Database_Operation_Insert;
$op->execute(
$this->_dbconn,
);
$this->_sethtmlGlobals();
- civicrm_api('uf_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
+ $this->callAPISuccess('uf_field', 'getfields', array('cache_clear' => 1));
$this->_params = array(
'field_name' => 'phone',
'is_active' => 1,
'location_type_id' => 1,
'phone_type_id' => 1,
- 'version' => $this->_apiversion,
'uf_group_id' => $this->_ufGroupId,
);
}
*/
public function testCreateUFField() {
$params = $this->_params; // copy
- $ufField = civicrm_api('uf_field', 'create', $params);
- $this->documentMe($params, $ufField, __FUNCTION__, __FILE__);
- unset($params['version']);
+ $ufField = $this->callAPIAndDocument('uf_field', 'create', $params, __FUNCTION__, __FILE__);
unset($params['uf_group_id']);
- $this->assertAPISuccess($ufField, " in line " . __LINE__);
$this->_ufFieldId = $ufField['id'];
foreach ($params as $key => $value) {
$this->assertEquals($ufField['values'][$ufField['id']][$key], $params[$key]);
);
$params = array(
- 'version' => $this->_apiversion,
'uf_group_id' => $this->_ufGroupId,
'option.autoweight' => FALSE,
'values' => $baseFields,
);
- $result = civicrm_api('uf_field', 'replace', $params);
- $this->assertAPISuccess($result);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument('uf_field', 'replace', $params, __FUNCTION__, __FILE__);
$inputsByName = CRM_Utils_Array::index(array('field_name'), $params['values']);
$this->assertEquals(count($params['values']), count($result['values']));
foreach ($result['values'] as $outUfField) {
'entity_id' => 1,
'weight' => 1,
'uf_group_id' => $this->_ufGroupId,
- 'is_active' => 1,
- 'version' => $this->_apiversion,
- );
- $ufJoin = civicrm_api('uf_join', 'create', $params);
+ 'is_active' => 1, );
+ $ufJoin = $this->callAPISuccess('uf_join', 'create', $params);
$searchParams = array(
'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => 1,
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('uf_join', 'get', $searchParams);
+ 'entity_id' => 1, );
+ $result = $this->callAPISuccess('uf_join', 'get', $searchParams);
foreach ($result['values'] as $key => $value) {
$this->assertEquals($value['uf_group_id'], $this->_ufGroupId, 'In line ' . __LINE__);
'entity_table' => 'civicrm_contribution_page',
'entity_id' => 1,
'weight' => 1,
- 'is_active' => 1,
- 'version' => $this->_apiversion,
- );
+ 'is_active' => 1, );
$result = $this->callAPIFailure('uf_join', 'create', $params);
$this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: uf_group_id', 'In line ' . __LINE__);
}
'entity_id' => 1,
'weight' => 1,
'uf_group_id' => $this->_ufGroupId,
- 'is_active' => 1,
- 'version' => $this->_apiversion,
- 'sequential' => 1,
+ 'is_active' => 1, 'sequential' => 1,
);
- $ufJoin = civicrm_api('uf_join', 'create', $params);
- $this->documentMe($params, $ufJoin, __FUNCTION__, __FILE__);
+ $ufJoin = $this->callAPIAndDocument('uf_join', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($ufJoin['values'][0]['module'], $params['module'], 'In line ' . __LINE__);
$this->assertEquals($ufJoin['values'][0]['uf_group_id'], $params['uf_group_id'], 'In line ' . __LINE__);
$this->assertEquals($ufJoin['values'][0]['is_active'], $params['is_active'], 'In line ' . __LINE__);
'entity_id' => 1,
'weight' => 1,
'uf_group_id' => $this->_ufGroupId,
- 'is_active' => 0,
- 'version' => $this->_apiversion,
- 'sequential' => 1,
+ 'is_active' => 0, 'sequential' => 1,
);
- $ufJoinUpdated = civicrm_api('uf_join', 'create', $params);
+ $ufJoinUpdated = $this->callAPISuccess('uf_join', 'create', $params);
$this->assertEquals($ufJoinUpdated['values'][0]['module'], $params['module'], 'In line ' . __LINE__);
$this->assertEquals($ufJoinUpdated['values'][0]['uf_group_id'], $params['uf_group_id'], 'In line ' . __LINE__);
$this->assertEquals($ufJoinUpdated['values'][0]['is_active'], $params['is_active'], 'In line ' . __LINE__);
'entity_id' => 1,
'weight' => 1,
'uf_group_id' => $this->_ufGroupId,
- 'is_active' => 1,
- 'version' => $this->_apiversion,
- );
+ 'is_active' => 1, );
- $ufJoin = civicrm_api('uf_join', 'create', $params);
+ $ufJoin = $this->callAPISuccess('uf_join', 'create', $params);
$searchParams = array(
'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => 1,
- 'version' => $this->_apiversion,
- 'sequential' => 1,
+ 'entity_id' => 1, 'sequential' => 1,
);
- $result = civicrm_api('uf_join', 'get', $searchParams);
- $this->documentMe($searchParams, $result, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument('uf_join', 'get', $searchParams, __FUNCTION__, __FILE__);
$this->assertEquals($result['values'][0]['module'], $params['module'], 'In line ' . __LINE__);
$this->assertEquals($result['values'][0]['uf_group_id'], $params['uf_group_id'], 'In line ' . __LINE__);
$this->assertEquals($result['values'][0]['entity_id'], $params['entity_id'], 'In line ' . __LINE__);
<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
'contact_id' => $this->_contactId,
'uf_id' => '2',
'uf_name' => 'blahdyblah@gmail.com',
- 'version' => '3',
'domain_id' => 1,
);
}
public function testGetUFMatchID() {
$params = array(
'uf_id' => 42,
- 'version' => $this->_apiversion,
);
- $result = civicrm_api('uf_match', 'get', $params);
+ $result = $this->callAPISuccess('uf_match', 'get', $params);
$this->assertEquals($result['values'][$result['id']]['contact_id'], 69);
- $this->assertAPISuccess($result);
}
function testGetUFMatchIDWrongParam() {
public function testGetUFID() {
$params = array(
'contact_id' => 69,
- 'version' => $this->_apiversion,
);
- $result = civicrm_api('uf_match', 'get', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument('uf_match', 'get', $params, __FUNCTION__, __FILE__);
$this->assertEquals($result['values'][$result['id']]['uf_id'], 42);
- $this->assertAPISuccess($result);
}
function testGetUFIDWrongParam() {
}
function testCreate() {
- $result = civicrm_api('uf_match', 'create', $this->_params);
- $this->assertAPISuccess($result);
+ $result = $this->callAPISuccess('uf_match', 'create', $this->_params);
$this->getAndCheck($this->_params, $result['id'], 'uf_match');
}
function testDelete() {
- $result = civicrm_api('uf_match', 'create', $this->_params);
- $this->assertEquals(1, civicrm_api('uf_match', 'getcount', array(
- 'version' => $this->_apiversion,
- 'id' => $result['id'],
+ $result = $this->callAPISuccess('uf_match', 'create', $this->_params);
+ $this->assertEquals(1, $this->callAPISuccess('uf_match', 'getcount', array( 'id' => $result['id'],
)));
- civicrm_api('uf_match', 'delete', array(
- 'version' => $this->_apiversion,
- 'id' => $result['id'],
+ $this->callAPISuccess('uf_match', 'delete', array( 'id' => $result['id'],
));
- $this->assertEquals(0, civicrm_api('uf_match', 'getcount', array(
- 'version' => $this->_apiversion,
- 'id' => $result['id'],
+ $this->assertEquals(0, $this->callAPISuccess('uf_match', 'getcount', array('id' => $result['id'],
)));
}
}
*/
class api_v3_WebsiteTest extends CiviUnitTestCase {
- protected $_apiversion;
+ protected $_apiversion = 3;
protected $params;
protected $id;
protected $_entity;
parent::setUp();
$this->_entity = 'website';
- $this->_apiversion = 3;
$this->_contactID = $this->organizationCreate();
$this->params = array(
- 'version' => 3,
'contact_id' => $this->_contactID,
'url' => 'website.com',
'website_type_id' => 1,
}
public function testCreateWebsite() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->getAndCheck($this->params, $result['id'], $this->_entity);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
}
public function testGetWebsite() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $result = civicrm_api($this->_entity, 'get', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $result = $this->callAPIAndDocument($this->_entity, 'get', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
- civicrm_api('website', 'delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess('website', 'delete', array('id' => $result['id']));
}
public function testDeleteWebsite() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->assertAPISuccess($result, 'in line ' . __LINE__);
- $deleteParams = array('version' => 3, 'id' => $result['id']);
- $result = civicrm_api($this->_entity, 'delete', $deleteParams);
- $this->documentMe($deleteParams, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
- $checkDeleted = civicrm_api($this->_entity, 'get', array(
- 'version' => 3,
- ));
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $deleteParams = array('id' => $result['id']);
+ $result = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__);
+ $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array());
$this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__);
}
public function testDeleteWebsiteInvalid() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->assertAPISuccess($result, 'in line ' . __LINE__);
- $deleteParams = array('version' => 3, 'id' => 600);
- $result = civicrm_api($this->_entity, 'delete', $deleteParams);
- $this->assertEquals(1,$result['is_error'], 'In line ' . __LINE__);
- $checkDeleted = civicrm_api($this->_entity, 'get', array(
- 'version' => 3,
- ));
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $deleteParams = array('id' => 600);
+ $result = $this->callAPIFailure($this->_entity, 'delete', $deleteParams);
+ $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array());
$this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__);
}
}
{literal}<?php{/literal}
/*
- *{$description}
+ *{if $description} {$description}{/if}
*/
function {$function}_example(){literal}{{/literal}
$params = {$params|@print_array};