Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
1b815fb3
Commit
1b815fb3
authored
4 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
[Test] - Fix some tests to call API not BAO
parent
137e207d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php
+10
-9
10 additions, 9 deletions
tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php
tests/phpunit/api/v3/MembershipTest.php
+7
-7
7 additions, 7 deletions
tests/phpunit/api/v3/MembershipTest.php
with
17 additions
and
16 deletions
tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php
+
10
−
9
View file @
1b815fb3
...
...
@@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/
use
Civi\Api4\MembershipType
;
/**
* Class CRM_Member_BAO_MembershipTypeTest
* @group headless
...
...
@@ -281,7 +283,6 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase {
*
*/
public
function
testGetRenewalDatesForMembershipType
()
{
$ids
=
[];
$params
=
[
'name'
=>
'General'
,
'domain_id'
=>
1
,
...
...
@@ -296,11 +297,11 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase {
'visibility'
=>
'Public'
,
'is_active'
=>
1
,
];
$membershipType
=
CRM_Member_BAO_
MembershipType
::
add
(
$params
,
$ids
)
;
$membershipType
ID
=
MembershipType
::
create
()
->
setValues
(
$params
)
->
execute
()
->
first
()[
'id'
]
;
$params
=
[
'contact_id'
=>
$this
->
_indiviContactID
,
'membership_type_id'
=>
$membershipType
->
id
,
'membership_type_id'
=>
$membershipType
ID
,
'join_date'
=>
'20060121000000'
,
'start_date'
=>
'20060121000000'
,
'end_date'
=>
'20070120000000'
,
...
...
@@ -309,15 +310,15 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase {
'status_id'
=>
$this
->
_membershipStatusID
,
];
$membership
=
CRM_Member_BAO_
Membership
::
create
(
$params
);
$membership
=
$this
->
callAPISuccess
(
'
Membership
'
,
'
create
'
,
$params
);
$membershipRenewDates
=
CRM_Member_BAO_MembershipType
::
getRenewalDatesForMembershipType
(
$membership
->
id
);
$membershipRenewDates
=
CRM_Member_BAO_MembershipType
::
getRenewalDatesForMembershipType
(
$membership
[
'id'
]
);
$this
->
assertEquals
(
$membershipRenewDates
[
'start_date'
],
'20060121'
,
'Verify membership renewal start date.'
);
$this
->
assertEquals
(
$membershipRenewDates
[
'end_date'
],
'20080120'
,
'Verify membership renewal end date.'
);
$this
->
assertEquals
(
'20060121'
,
$membershipRenewDates
[
'start_date'
],
'Verify membership renewal start date.'
);
$this
->
assertEquals
(
'20080120'
,
$membershipRenewDates
[
'end_date'
],
'Verify membership renewal end date.'
);
$this
->
membershipDelete
(
$membership
->
id
);
$this
->
membershipTypeDelete
([
'id'
=>
$membershipType
->
id
]);
$this
->
membershipDelete
(
$membership
[
'id'
]
);
$this
->
membershipTypeDelete
([
'id'
=>
$membershipType
ID
]);
}
/**
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/api/v3/MembershipTest.php
+
7
−
7
View file @
1b815fb3
...
...
@@ -1341,7 +1341,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase {
/**
* CRM-18503 - Test membership join date is correctly set for fixed memberships.
*
* @throws \CRM_Core_Exception
* @throws \CRM_Core_Exception
|\CiviCRM_API3_Exception
*/
public
function
testMembershipJoinDateFixed
()
{
$memStatus
=
CRM_Member_PseudoConstant
::
membershipStatus
();
...
...
@@ -1354,20 +1354,20 @@ class api_v3_MembershipTest extends CiviUnitTestCase {
'membership_type_id'
=>
$this
->
_membershipTypeID2
,
'source'
=>
'test membership'
,
'is_pay_later'
=>
0
,
'status_id'
=>
array_search
(
'Pending'
,
$memStatus
)
,
'status_id'
=>
'Pending'
,
'skipStatusCal'
=>
1
,
'is_for_organization'
=>
1
,
];
$membership
=
CRM_Member_BAO_
Membership
::
create
(
$params
);
$membership
=
$this
->
callAPISuccess
(
'
Membership
'
,
'
create
'
,
$params
);
// Update membership to 'Completed' and check the dates.
$memParams
=
[
'id'
=>
$membership
->
id
,
'id'
=>
$membership
[
'id'
]
,
'contact_id'
=>
$contactId
,
'is_test'
=>
0
,
'membership_type_id'
=>
$this
->
_membershipTypeID2
,
'num_terms'
=>
1
,
'status_id'
=>
array_search
(
'New'
,
$memStatus
)
,
'status_id'
=>
'New'
,
];
$result
=
$this
->
callAPISuccess
(
'Membership'
,
'create'
,
$memParams
);
...
...
@@ -1380,11 +1380,11 @@ class api_v3_MembershipTest extends CiviUnitTestCase {
$rollOver
=
FALSE
;
$startDate
=
date
(
'Y-m-d'
,
strtotime
(
date
(
'Y-03-01'
)
.
'- 1 year'
));
}
$membershipTypeDetails
=
CRM_Member_BAO_MembershipType
::
getMembershipType
Details
(
$this
->
_membershipTypeID2
);
$membershipTypeDetails
=
CRM_Member_BAO_MembershipType
::
getMembershipType
(
$this
->
_membershipTypeID2
);
$fixedPeriodRollover
=
CRM_Member_BAO_MembershipType
::
isDuringFixedAnnualRolloverPeriod
(
$joinDate
,
$membershipTypeDetails
,
$year
,
$startDate
);
$y
=
1
;
if
(
$fixedPeriodRollover
&&
$rollOver
)
{
$y
+=
1
;
++
$y
;
}
$expectedDates
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment