Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cleanup - remove direct calls to BAO_Membership::add #22497

Merged
merged 1 commit into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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