Skip to content

Commit

Permalink
Merge pull request #25688 from eileenmcnaughton/dep_test
Browse files Browse the repository at this point in the history
Remove deprecated functions from tests
  • Loading branch information
seamuslee001 authored Feb 28, 2023
2 parents 7ff841a + 2b8cc41 commit c894968
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/Form/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function testActivityDelete() {
'repetition_frequency_interval' => 1,
'start_action_offset' => $numberOfRepeatingActivitiesToCreate - 1,
];
$actionScheduleBao = CRM_Core_BAO_ActionSchedule::add($actionScheduleParams);
$actionScheduleBao = CRM_Core_BAO_ActionSchedule::writeRecord($actionScheduleParams);

// Create the activity's repeats.
$recurringEntityBao = new CRM_Core_BAO_RecurringEntity();
Expand Down
12 changes: 2 additions & 10 deletions tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function testAdd() {
$this->assertEquals($result->name, $params['name']);
$this->assertEquals($result->parent_id, $params['parent_id']);
$this->assertEquals($result->is_active, $params['is_active']);
CRM_Contact_BAO_ContactType::del($result->id);
CRM_Contact_BAO_ContactType::deleteRecord(['id' => $result->id]);

$params = [
'label' => 'householdSubType',
Expand All @@ -366,7 +366,7 @@ public function testAdd() {
$this->assertEquals($result->name, $params['name']);
$this->assertEquals($result->parent_id, $params['parent_id']);
$this->assertEquals($result->is_active, $params['is_active']);
CRM_Contact_BAO_ContactType::del($result->id);
CRM_Contact_BAO_ContactType::deleteRecord(['id' => $result->id]);
}

/**
Expand Down Expand Up @@ -429,12 +429,4 @@ public function testDel() {
$this->assertEquals(FALSE, in_array($subtype->name, $result, TRUE));
}

/**
* Test del() with invalid data
*/
public function testDelInvalid() {
$del = CRM_Contact_BAO_ContactType::del(NULL);
$this->assertEquals($del, FALSE);
}

}
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public function testAddPremium() {
$this->assertEquals($contributionProduct->product_id, $premium->id, 'Check for Product id .');

//Delete Product
CRM_Contribute_BAO_Product::del($premium->id);
CRM_Contribute_BAO_Product::deleteRecord(['id' => $premium->id]);
$this->assertDBNull('CRM_Contribute_DAO_Product', $premium->name,
'id', 'name', 'Database check for deleted Product.'
);
Expand Down
6 changes: 2 additions & 4 deletions tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function testAdd() {
'is_deductible' => 0,
'is_active' => 1,
];
$ids = [];
$contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$contributionType = CRM_Financial_BAO_FinancialType::writeRecord($params);

$result = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id,
'name', 'id',
Expand All @@ -54,8 +53,7 @@ public function testSetIsActive() {
'is_deductible' => 0,
'is_active' => 1,
];
$ids = [];
$contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$contributionType = CRM_Financial_BAO_FinancialType::writeRecord($params);
$result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0);
$this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.');

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/BAO/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testDel() {
];

$product = CRM_Contribute_BAO_Product::create($params);
CRM_Contribute_BAO_Product::del($product->id);
CRM_Contribute_BAO_Product::deleteRecord(['id' => $product->id]);

$params = ['id' => $product->id];
$defaults = [];
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ public function testContactModifiedAnniversary(): void {
$modifiedDate = $this->callAPISuccess('Contact', 'getvalue', ['id' => $contact['id'], 'return' => 'modified_date']);
$actionSchedule = $this->createScheduleFromFixtures('sched_contact_mod_anniversary');
$actionSchedule['effective_start_date'] = date('Y-m-d H:i:s', strtotime($contact['values'][$contact['id']]['modified_date']));
$actionScheduleDao = CRM_Core_BAO_ActionSchedule::add($actionSchedule);
$actionScheduleDao = CRM_Core_BAO_ActionSchedule::writeRecord($actionSchedule);
$this->assertCronRuns([
[
// On some random day, no email.
Expand Down Expand Up @@ -2020,7 +2020,7 @@ public function testMembershipOnMultipleReminder(): void {
$actionScheduleAfter['effective_end_date'] = '2012-06-16 02:00:00';
$actionScheduleBefore['entity_value'] = $actionScheduleOn['entity_value'] = $actionScheduleAfter['entity_value'] = $membership['membership_type_id'];
foreach (['actionScheduleBefore', 'actionScheduleOn', 'actionScheduleAfter'] as $value) {
$$value = CRM_Core_BAO_ActionSchedule::add($$value);
$$value = CRM_Core_BAO_ActionSchedule::writeRecord($$value);
}

$this->assertCronRuns(
Expand Down Expand Up @@ -2546,7 +2546,7 @@ public function testRepetitionFrequencyUnit(): void {
$actionScheduleParams['entity_value'] = $membershipType->id;
$actionScheduleParams['repetition_frequency_unit'] = $interval_unit;
$actionScheduleParams['repetition_frequency_interval'] = 2;
$actionSchedule = CRM_Core_BAO_ActionSchedule::add($actionScheduleParams);
$actionSchedule = CRM_Core_BAO_ActionSchedule::writeRecord($actionScheduleParams);
$beforeEndDate = $this->createModifiedDateTime($membershipEndDate, '-1 day');
$beforeFirstUnit = $this->createModifiedDateTime($membershipEndDate, "+1 $interval_unit");
$afterFirstUnit = $this->createModifiedDateTime($membershipEndDate, "+2 $interval_unit");
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function createActionSchedule($entity_id, $entity_table) {
"start_action_condition" => "monday,tuesday,wednesday,thursday,friday,saturday",
"start_action_offset" => "2",
];
$actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($params);
$actionScheduleObj = CRM_Core_BAO_ActionSchedule::writeRecord($params);
return $actionScheduleObj;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Core/BAO/UFGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testPreHookIsCalledForDelete() {
];
$ufGroup = CRM_Core_BAO_UFGroup::add($params);
$ufGroupID = $ufGroup->id;
$ufGroup = CRM_Core_BAO_UFGroup::del($ufGroupID);
$ufGroup = CRM_Core_BAO_UFGroup::deleteRecord(['id' => $ufGroupID]);

// Assert that pre hook implemntation was called for delete op.
$systemLogCount = $this->callAPISuccess('SystemLog', 'getcount', [
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testPostHookIsCalledForDelete() {
];
$ufGroup = CRM_Core_BAO_UFGroup::add($params);
$ufGroupID = $ufGroup->id;
$ufGroup = CRM_Core_BAO_UFGroup::del($ufGroupID);
$ufGroup = CRM_Core_BAO_UFGroup::deleteRecord(['id' => $ufGroupID]);

// Assert that pre hook implemntation was called for delete op.
$systemLogCount = $this->callAPISuccess('SystemLog', 'getcount', [
Expand Down
15 changes: 6 additions & 9 deletions tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public function testAdd() {
'is_deductible' => 0,
'is_active' => 1,
];
$ids = [];
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params);

$result = $this->assertDBNotNull(
'CRM_Financial_BAO_FinancialAccount',
Expand All @@ -56,8 +55,8 @@ public function testRetrieve() {
'is_deductible' => 0,
'is_active' => 1,
];
$ids = $defaults = [];
CRM_Financial_BAO_FinancialAccount::add($params);
$defaults = [];
CRM_Financial_BAO_FinancialAccount::writeRecord($params);

$result = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults);

Expand All @@ -73,8 +72,7 @@ public function testSetIsActive() {
'is_deductible' => 0,
'is_active' => 1,
];
$ids = [];
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
$financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params);
$result = CRM_Financial_BAO_FinancialAccount::setIsActive($financialAccount->id, 0);
$this->assertEquals($result, TRUE, 'Verify financial account record updation for is_active.');

Expand All @@ -99,7 +97,7 @@ public function testDel() {
'is_deductible' => 0,
'is_active' => 1,
];
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params);
$financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params);

CRM_Financial_BAO_FinancialAccount::del($financialAccount->id);
$params = ['id' => $financialAccount->id];
Expand Down Expand Up @@ -149,8 +147,7 @@ public function testGetAccountingCode() {
'is_reserved' => 0,
];

$ids = [];
$financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
$financialType = CRM_Financial_BAO_FinancialType::writeRecord($params);
$financialAccountid = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', 'Donations', 'id', 'name');
CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccountid, 'accounting_code', '4800');
$accountingCode = CRM_Financial_BAO_FinancialAccount::getAccountingCode($financialType->id);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testCreateEntityTrxn(): CRM_Financial_DAO_EntityFinancialTrxn {
];

$amount = 200;
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($fParams);
$financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($fParams);
$financialTrxn = new CRM_Financial_DAO_FinancialTrxn();
$financialTrxn->to_financial_account_id = $financialAccount->id;
$financialTrxn->total_amount = $amount;
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ public function createFinancialAccount($financialAccountType, $relationType = NU
'is_reserved' => 0,
'financial_account_type_id' => array_search($financialAccountType, $financialAccountTypes),
];
$financialAccount = CRM_Financial_BAO_FinancialAccount::add($params);
$financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params);
$financialType = $financialAccountType = NULL;
if ($relationType) {
$params['name'] = 'test_financialType1';
$financialType = CRM_Financial_BAO_FinancialType::add($params);
$financialType = CRM_Financial_BAO_FinancialType::writeRecord($params);
$financialParams = [
'entity_table' => 'civicrm_financial_type',
'entity_id' => $financialType->id,
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Member/BAO/MembershipLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function tearDown(): void {
*/
public function testDel() {
list($contactID, $membershipID) = $this->setupMembership();
CRM_Member_BAO_MembershipLog::del($membershipID);
CRM_Member_BAO_MembershipLog::deleteRecord(['id' => $membershipID]);
$this->assertDBNull('CRM_Member_BAO_MembershipLog', $membershipID, 'membership_id',
'id', 'Database check for deleted membership log.'
);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testDel() {
$params = ['name' => 'testStatus', 'is_active' => 1];

$membershipID = $this->callAPISuccess('MembershipStatus', 'create', $params)['id'];
CRM_Member_BAO_MembershipStatus::del($membershipID);
CRM_Member_BAO_MembershipStatus::deleteRecord(['id' => $membershipID]);
$defaults = [];
$result = CRM_Member_BAO_MembershipStatus::retrieve($params, $defaults);
$this->assertEquals($result === NULL, TRUE, 'Verify membership status record deletion.');
Expand Down
12 changes: 0 additions & 12 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,18 +556,6 @@ public function createTestEntity() {
return $entity = $this->callAPISuccess($this->entity, 'create', $this->params);
}

/**
* @param int $contactTypeId
*
* @throws Exception
*/
public function contactTypeDelete($contactTypeId) {
$result = CRM_Contact_BAO_ContactType::del($contactTypeId);
if (!$result) {
throw new Exception('Could not delete contact type');
}
}

/**
* @param array $params
*
Expand Down

0 comments on commit c894968

Please sign in to comment.