Skip to content

Commit

Permalink
Test cleanup - remove direct calls to BAO_Membership::add
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jan 13, 2022
1 parent 156c4c2 commit 722682e
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 148 deletions.
14 changes: 8 additions & 6 deletions tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/

use Civi\Api4\MembershipType;

/**
* Class CRM_Financial_BAO_FinancialTypeTest
* @group headless
Expand Down Expand Up @@ -173,11 +175,12 @@ public function testGetAvailableFinancialTypes() {
}

/**
* Check method testgetAvailableMembershipTypes()
* Check method test getAvailableMembershipTypes()
*
* @throws \API_Exception
*/
public function testgetAvailableMembershipTypes() {
public function testGetAvailableMembershipTypes(): void {
// Create Membership types
$ids = [];
$params = [
'name' => 'Type One',
'domain_id' => 1,
Expand All @@ -190,12 +193,11 @@ public function testgetAvailableMembershipTypes() {
'visibility' => 'Public',
'is_active' => 1,
];

$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
MembershipType::create()->setValues($params)->execute();
// Add another
$params['name'] = 'Type Two';
$params['financial_type_id'] = 2;
$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
MembershipType::create()->setValues($params)->execute();

$this->setACL();

Expand Down
11 changes: 6 additions & 5 deletions tests/phpunit/CRM/Member/BAO/MembershipLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* <http://www.gnu.org/licenses/>.
*/

use Civi\Api4\MembershipType;

/**
* Test CRM/Member/BAO Membership Log add , delete functions
*
Expand Down Expand Up @@ -61,7 +63,7 @@ class CRM_Member_BAO_MembershipLogTest extends CiviUnitTestCase {
* Set up for test.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \API_Exception
*/
public function setUp(): void {
parent::setUp();
Expand Down Expand Up @@ -91,15 +93,14 @@ public function setUp(): void {
'visibility' => 'Public',
'is_active' => 1,
];
$membershipType = CRM_Member_BAO_MembershipType::add($params);
$this->membershipTypeID = $membershipType->id;
$this->membershipTypeID = MembershipType::create()->setValues($params)->execute()->first()['id'];
$this->membershipStatusID = $this->membershipStatusCreate('test status');
}

/**
* Tears down the fixture.
*
* @throws \CRM_Core_Exception
* @throws \API_Exception
*/
public function tearDown(): void {
$this->relationshipTypeDelete($this->relationshipTypeID);
Expand Down Expand Up @@ -147,7 +148,7 @@ public function testResetModifiedID() {
*
* @throws \CRM_Core_Exception
*/
public function testCreateMembershipWithPassedInModifiedID() {
public function testCreateMembershipWithPassedInModifiedID(): void {
$modifier = $this->individualCreate();
$membershipID = $this->setupMembership($modifier)[1];
$this->assertEquals($modifier, $this->callAPISuccessGetValue('MembershipLog', ['membership_id' => $membershipID, 'return' => 'modified_id']));
Expand Down
Loading

0 comments on commit 722682e

Please sign in to comment.