From e6ff1593c1e40bcea1fec24827baaa2e67005e67 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 26 Jul 2013 14:13:33 +1200 Subject: [PATCH] CRM-13072 completely remove all references to the contributionCreate and contributionDelete functions that have caused a lot of problems for a long time & are currently causing tests to fail --- .../Contribute/BAO/ContributionPageTest.php | 17 +++--- .../CRM/Contribute/BAO/ContributionTest.php | 14 +++-- .../CRM/Core/BAO/FinancialTrxnTest.php | 6 +-- .../CRM/Core/Payment/AuthorizeNetTest.php | 20 +++---- .../CRM/Member/BAO/MembershipLogTest.php | 5 +- .../CRM/Member/BAO/MembershipTypeTest.php | 23 ++++---- .../Member/Import/Parser/MembershipTest.php | 5 +- .../phpunit/CRM/Utils/DeprecatedUtilsTest.php | 1 - tests/phpunit/CiviTest/CiviUnitTestCase.php | 54 ------------------- tests/phpunit/api/v3/ImTest.php | 37 +++++-------- tests/phpunit/api/v3/ParticipantTest.php | 2 +- tests/phpunit/api/v3/UFFieldTest.php | 17 ++---- tests/phpunit/api/v3/UFJoinTest.php | 42 +++++---------- tests/phpunit/api/v3/UFMatchTest.php | 28 +++------- tests/phpunit/api/v3/WebsiteTest.php | 41 +++++--------- tests/templates/documentFunction.tpl | 2 +- 16 files changed, 94 insertions(+), 220 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php index d8fabb9637..115e0708cb 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php @@ -42,11 +42,10 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { function setUp() { parent::setUp(); - $this->_contributionTypeID = $this->contributionTypeCreate(); + $this->_financialTypeID = 1; } function tearDown() { - $this->contributionTypeDelete(); } /** @@ -57,7 +56,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $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, @@ -88,7 +87,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $params = array( 'title' => 'Test Contribution Page', - 'financial_type_id' => $this->_contributionTypeID, + 'financial_type_id' => $this->_financialTypeID, 'is_active' => 1, ); @@ -107,7 +106,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $params = array( 'title' => 'Test Contribution Page', - 'financial_type_id' => $this->_contributionTypeID, + 'financial_type_id' => $this->_financialTypeID, 'is_active' => 1, ); @@ -118,7 +117,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $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); } @@ -130,7 +129,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $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, @@ -149,7 +148,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $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); @@ -162,7 +161,7 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $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, ); diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 28f5a1080f..0f5b0e1fb5 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -40,11 +40,9 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { function setUp() { parent::setUp(); - $this->contributionTypeCreate(); } function teardown() { - $this->contributionTypeDelete(); } /** @@ -115,7 +113,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $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', @@ -176,7 +174,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $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', @@ -235,7 +233,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $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, @@ -298,7 +296,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $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', @@ -362,7 +360,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $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', @@ -418,7 +416,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $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', diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php index d5a5a8d9f5..052ca6c785 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php @@ -44,10 +44,10 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase { */ 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', diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php index d35872a40a..ca3e8d16af 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -54,7 +54,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { ); $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 @@ -63,7 +63,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { 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); } @@ -78,7 +78,6 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { $nameParams = array('first_name' => $firstName, 'last_name' => $lastName); $contactId = Contact::createIndividual($nameParams); - $ids = array('contribution' => NULL); $invoiceID = sha1(rand()); $amount = rand(100, 1000) . '.00'; @@ -100,7 +99,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { $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, @@ -133,7 +132,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { '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'), @@ -179,7 +178,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { 'email' => "{$firstName}.{$lastName}@example.com", 'contactID' => $contactId, 'contributionID' => $contribution->id, - 'contributionTypeID' => $this->_contributionTypeId, + 'contributionTypeID' => $this->_financialTypeId, 'contributionRecurID' => $recur->id, ); @@ -235,7 +234,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { $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, @@ -244,7 +243,8 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { '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', @@ -268,7 +268,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { '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, @@ -315,7 +315,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { 'email' => "{$firstName}.{$lastName}@example.com", 'contactID' => $contactId, 'contributionID' => $contribution->id, - 'contributionTypeID' => $this->_contributionTypeId, + 'contributionTypeID' => $this->_financialTypeId, 'contributionRecurID' => $recur->id, ); diff --git a/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php b/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php index bb773f3a93..2f5880c9f2 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipLogTest.php @@ -53,7 +53,7 @@ class CRM_Member_BAO_MembershipLogTest extends CiviUnitTestCase { ); $this->_relationshipTypeId = $this->relationshipTypeCreate($params); $this->_orgContactID = $this->organizationCreate(); - $this->_contributionTypeId = $this->contributionTypeCreate(); + $this->_financialTypeId = 1; $params = array( 'name' => 'test type', @@ -63,7 +63,7 @@ class CRM_Member_BAO_MembershipLogTest extends CiviUnitTestCase { '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, @@ -82,7 +82,6 @@ class CRM_Member_BAO_MembershipLogTest extends CiviUnitTestCase { $this->relationshipTypeDelete($this->_relationshipTypeId); $this->membershipTypeDelete(array('id' => $this->_membershipTypeID)); $this->membershipStatusDelete($this->_mebershipStatusID); - $this->contributionTypeDelete(NULL); $this->contactDelete($this->_orgContactID); } diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php index f6feaedc64..360d3a2115 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php @@ -51,7 +51,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { $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'); } @@ -63,7 +63,6 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { function tearDown() { $this->relationshipTypeDelete($this->_relationshipTypeId); $this->membershipStatusDelete($this->_membershipStatusID); - $this->contributionTypeDelete(); $this->contactDelete($this->_orgContactID); $this->contactDelete($this->_indiviContactID); } @@ -82,7 +81,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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', ); @@ -112,7 +111,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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', ); @@ -139,7 +138,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -171,7 +170,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -199,7 +198,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -227,7 +226,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -252,7 +251,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -279,7 +278,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -305,7 +304,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, @@ -348,7 +347,7 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { '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, diff --git a/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php b/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php index 7ad1ae7bf6..3e98792918 100644 --- a/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php @@ -70,7 +70,7 @@ class CRM_Member_Import_Parser_MembershipTest extends CiviUnitTestCase { ); $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, @@ -80,7 +80,7 @@ class CRM_Member_Import_Parser_MembershipTest extends CiviUnitTestCase { '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, @@ -106,7 +106,6 @@ class CRM_Member_Import_Parser_MembershipTest extends CiviUnitTestCase { $this->relationshipTypeDelete($this->_relationshipTypeId); $this->membershipTypeDelete(array('id' => $this->_membershipTypeID)); $this->membershipStatusDelete($this->_mebershipStatusID); - $this->contributionTypeDelete(NULL); $this->contactDelete($this->_orgContactID); } diff --git a/tests/phpunit/CRM/Utils/DeprecatedUtilsTest.php b/tests/phpunit/CRM/Utils/DeprecatedUtilsTest.php index e2c891cb2c..fd84c662b3 100644 --- a/tests/phpunit/CRM/Utils/DeprecatedUtilsTest.php +++ b/tests/phpunit/CRM/Utils/DeprecatedUtilsTest.php @@ -26,7 +26,6 @@ class CRM_Utils_DeprecatedUtilsTest extends CiviUnitTestCase { ); $this->quickCleanup($tablesToTruncate); - $this->contributionTypeDelete(); } /** * Test civicrm_contact_check_params with no contact type diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index f2af7d0f60..2744019cfd 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1156,60 +1156,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { 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 * diff --git a/tests/phpunit/api/v3/ImTest.php b/tests/phpunit/api/v3/ImTest.php index e27e554b2e..f7629bc6f8 100644 --- a/tests/phpunit/api/v3/ImTest.php +++ b/tests/phpunit/api/v3/ImTest.php @@ -36,7 +36,7 @@ require_once 'CiviTest/CiviUnitTestCase.php'; */ class api_v3_ImTest extends CiviUnitTestCase { - protected $_apiversion; + protected $_apiversion = 3; protected $params; protected $id; protected $_entity; @@ -47,10 +47,8 @@ class api_v3_ImTest extends CiviUnitTestCase { 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, @@ -66,41 +64,32 @@ class api_v3_ImTest extends CiviUnitTestCase { } 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__); } } diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index 27ae60451e..f1a617bb04 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -678,7 +678,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { * 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"; diff --git a/tests/phpunit/api/v3/UFFieldTest.php b/tests/phpunit/api/v3/UFFieldTest.php index 6762723023..f293afed79 100644 --- a/tests/phpunit/api/v3/UFFieldTest.php +++ b/tests/phpunit/api/v3/UFFieldTest.php @@ -1,5 +1,4 @@ _apiversion = 3; $op = new PHPUnit_Extensions_Database_Operation_Insert; $op->execute( $this->_dbconn, @@ -66,7 +64,7 @@ class api_v3_UFFieldTest extends CiviUnitTestCase { ); $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', @@ -78,7 +76,6 @@ class api_v3_UFFieldTest extends CiviUnitTestCase { 'is_active' => 1, 'location_type_id' => 1, 'phone_type_id' => 1, - 'version' => $this->_apiversion, 'uf_group_id' => $this->_ufGroupId, ); } @@ -100,11 +97,8 @@ class api_v3_UFFieldTest extends CiviUnitTestCase { */ 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]); @@ -199,15 +193,12 @@ class api_v3_UFFieldTest extends CiviUnitTestCase { ); $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) { diff --git a/tests/phpunit/api/v3/UFJoinTest.php b/tests/phpunit/api/v3/UFJoinTest.php index 9d81255ca7..45b4d6e888 100644 --- a/tests/phpunit/api/v3/UFJoinTest.php +++ b/tests/phpunit/api/v3/UFJoinTest.php @@ -134,17 +134,13 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { '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__); @@ -170,9 +166,7 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { '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__); } @@ -187,12 +181,9 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { '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__); @@ -204,11 +195,9 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { '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__); @@ -248,20 +237,15 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { '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__); diff --git a/tests/phpunit/api/v3/UFMatchTest.php b/tests/phpunit/api/v3/UFMatchTest.php index dc1f7919aa..f43811e471 100644 --- a/tests/phpunit/api/v3/UFMatchTest.php +++ b/tests/phpunit/api/v3/UFMatchTest.php @@ -1,5 +1,4 @@ $this->_contactId, 'uf_id' => '2', 'uf_name' => 'blahdyblah@gmail.com', - 'version' => '3', 'domain_id' => 1, ); } @@ -94,11 +92,9 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { 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() { @@ -112,12 +108,9 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { 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() { @@ -136,24 +129,17 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { } 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'], ))); } } diff --git a/tests/phpunit/api/v3/WebsiteTest.php b/tests/phpunit/api/v3/WebsiteTest.php index c2cc0f4046..0005e440d4 100644 --- a/tests/phpunit/api/v3/WebsiteTest.php +++ b/tests/phpunit/api/v3/WebsiteTest.php @@ -36,7 +36,7 @@ require_once 'CiviTest/CiviUnitTestCase.php'; */ class api_v3_WebsiteTest extends CiviUnitTestCase { - protected $_apiversion; + protected $_apiversion = 3; protected $params; protected $id; protected $_entity; @@ -47,10 +47,8 @@ class api_v3_WebsiteTest extends CiviUnitTestCase { 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, @@ -65,45 +63,32 @@ class api_v3_WebsiteTest extends CiviUnitTestCase { } 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__); } } diff --git a/tests/templates/documentFunction.tpl b/tests/templates/documentFunction.tpl index 9343e575d6..0457fe793d 100644 --- a/tests/templates/documentFunction.tpl +++ b/tests/templates/documentFunction.tpl @@ -1,7 +1,7 @@ {literal}