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
032b095c
Commit
032b095c
authored
4 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test that ultimately failed to hit the desired code but does add cover
parent
88786666
No related branches found
Branches containing commit
No related tags found
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/Form/MembershipRenewalTest.php
+13
-3
13 additions, 3 deletions
tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
tests/phpunit/CRMTraits/Custom/CustomDataTrait.php
+10
-4
10 additions, 4 deletions
tests/phpunit/CRMTraits/Custom/CustomDataTrait.php
with
23 additions
and
7 deletions
tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
+
13
−
3
View file @
032b095c
...
...
@@ -18,6 +18,7 @@ use Civi\Api4\Contact;
* @group headless
*/
class
CRM_Member_Form_MembershipRenewalTest
extends
CiviUnitTestCase
{
use
CRMTraits_Custom_CustomDataTrait
;
protected
$_individualId
;
protected
$_contribution
;
...
...
@@ -119,7 +120,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
'civicrm_relationship'
,
'civicrm_uf_match'
,
'civicrm_address'
,
]
]
,
TRUE
);
foreach
(
$this
->
ids
[
'contact'
]
as
$contactID
)
{
$this
->
callAPISuccess
(
'contact'
,
'delete'
,
[
'id'
=>
$contactID
,
'skip_undelete'
=>
TRUE
]);
...
...
@@ -404,6 +405,9 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
*/
public
function
testSubmitRecurCompleteInstantWithMail
(
$thousandSeparator
)
{
$this
->
setCurrencySeparators
(
$thousandSeparator
);
// Visibility is 'Public Pages and Listings' in order to try to get to a specific line
// of code to ensure it's tested - it might not be a 'real' use case.
$this
->
createCustomGroupWithFieldOfType
([
'extends'
=>
'Membership'
],
'multi_country'
,
NULL
,
[
'visibility'
=>
'Public Pages and Listings'
]);
$form
=
$this
->
getForm
();
$this
->
mut
=
new
CiviMailUtils
(
$this
,
TRUE
);
/** @var \CRM_Core_Payment_Dummy $processor */
...
...
@@ -424,13 +428,19 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
$form
->
preProcess
();
$form
->
_contactID
=
$this
->
_individualId
;
$form
->
_mode
=
'
test
'
;
$form
->
_mode
=
'
live
'
;
$form
->
testSubmit
(
array_merge
(
$this
->
getBaseSubmitParams
(),
[
'is_recur'
=>
1
,
'send_receipt'
=>
1
,
'auto_renew'
=>
1
]));
$form
->
testSubmit
(
array_merge
(
$this
->
getBaseSubmitParams
(),
[
'is_recur'
=>
1
,
'send_receipt'
=>
1
,
'auto_renew'
=>
1
,
$this
->
getCustomFieldName
(
'multi_country'
)
=>
[
1006
,
1007
],
]));
$contributionRecur
=
$this
->
callAPISuccessGetSingle
(
'ContributionRecur'
,
[
'contact_id'
=>
$this
->
_individualId
]);
$this
->
assertEquals
(
1
,
$contributionRecur
[
'is_email_receipt'
]);
$this
->
mut
->
checkMailLog
([
'$ '
.
$this
->
formatMoneyInput
(
7800.90
),
'Country-multi : Angola, Anguilla'
,
]);
$this
->
mut
->
stop
();
$this
->
setCurrencySeparators
(
','
);
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRMTraits/Custom/CustomDataTrait.php
+
10
−
4
View file @
032b095c
...
...
@@ -86,14 +86,16 @@ trait CRMTraits_Custom_CustomDataTrait {
* Params for the group to be created.
* @param string $customFieldType
*
* @param string $identifier
* @param string|null $identifier
*
* @param array $fieldParams
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public
function
createCustomGroupWithFieldOfType
(
$groupParams
=
[],
$customFieldType
=
'text'
,
$identifier
=
NULL
)
{
$supported
=
[
'text'
,
'select'
,
'date'
,
'int'
,
'contact_reference'
,
'radio'
];
public
function
createCustomGroupWithFieldOfType
(
$groupParams
=
[],
$customFieldType
=
'text'
,
$identifier
=
NULL
,
$fieldParams
=
[]
)
{
$supported
=
[
'text'
,
'select'
,
'date'
,
'int'
,
'contact_reference'
,
'radio'
,
'multi_country'
];
if
(
!
in_array
(
$customFieldType
,
$supported
,
TRUE
))
{
throw
new
CRM_Core_Exception
(
'we have not yet extracted other custom field types from createCustomFieldsOfAllTypes, Use consistent syntax when you do'
);
}
...
...
@@ -101,7 +103,7 @@ trait CRMTraits_Custom_CustomDataTrait {
$groupParams
[
'name'
]
=
$identifier
??
'Custom Group'
;
$this
->
createCustomGroup
(
$groupParams
);
$reference
=
&
$this
->
ids
[
'CustomField'
][
$identifier
.
$customFieldType
];
$fieldParams
=
[
'custom_group_id'
=>
$this
->
ids
[
'CustomGroup'
][
$groupParams
[
'name'
]]];
$fieldParams
=
array_merge
(
$fieldParams
,
[
'custom_group_id'
=>
$this
->
ids
[
'CustomGroup'
][
$groupParams
[
'name'
]]]
)
;
switch
(
$customFieldType
)
{
case
'text'
:
$reference
=
$this
->
createTextCustomField
(
$fieldParams
)[
'id'
];
...
...
@@ -127,6 +129,10 @@ trait CRMTraits_Custom_CustomDataTrait {
$reference
=
$this
->
createIntegerRadioCustomField
(
$fieldParams
)[
'id'
];
return
;
case
'multi_country'
:
$reference
=
$this
->
createMultiCountryCustomField
(
$fieldParams
)[
'id'
];
return
;
}
}
...
...
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