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
c1ddf71b
Commit
c1ddf71b
authored
3 years ago
by
Eileen McNaughton
Browse files
Options
Downloads
Patches
Plain Diff
Add related contact display test
parent
9dfeb510
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/phpunit/CRM/Contact/BAO/QueryTest.php
+49
-0
49 additions, 0 deletions
tests/phpunit/CRM/Contact/BAO/QueryTest.php
with
49 additions
and
0 deletions
tests/phpunit/CRM/Contact/BAO/QueryTest.php
+
49
−
0
View file @
c1ddf71b
...
...
@@ -1317,4 +1317,53 @@ civicrm_relationship.is_active = 1 AND
$this
->
assertEquals
(
'World Region = Middle East and North Africa'
,
$query
->
_qill
[
0
][
0
]);
}
/**
* Tests the advanced search query by searching on related contacts and contact type same time.
*
* Preparation:
* Create an individual contact Contact A
* Create an organization contact Contact B
* Create an "Employer of" relationship between them.
*
* Searching:
* Go to advanced search
* Click on View contact as related contact
* Select Employee of as relationship type
* Select "Organization" as contact type
*
* Expected results
* We expect to find contact A.
*
* @throws \Exception
*/
public
function
testAdvancedSearchWithDisplayRelationshipsAndContactType
():
void
{
$employeeRelationshipTypeId
=
$this
->
callAPISuccess
(
'RelationshipType'
,
'getvalue'
,
[
'return'
=>
'id'
,
'name_a_b'
=>
'Employee of'
]);
$indContactID
=
$this
->
individualCreate
([
'first_name'
=>
'John'
,
'last_name'
=>
'Smith'
]);
$orgContactID
=
$this
->
organizationCreate
([
'contact_type'
=>
'Organization'
,
'organization_name'
=>
'Healthy Planet Fund'
]);
$this
->
callAPISuccess
(
'Relationship'
,
'create'
,
[
'contact_id_a'
=>
$indContactID
,
'contact_id_b'
=>
$orgContactID
,
'relationship_type_id'
=>
$employeeRelationshipTypeId
]);
// Search setup
$formValues
=
[
'display_relationship_type'
=>
$employeeRelationshipTypeId
.
'_a_b'
,
'contact_type'
=>
'Organization'
];
$params
=
CRM_Contact_BAO_Query
::
convertFormValues
(
$formValues
,
0
,
FALSE
,
NULL
,
[]);
$isDeleted
=
FALSE
;
$selector
=
new
CRM_Contact_Selector
(
'CRM_Contact_Selector'
,
$formValues
,
$params
,
NULL
,
CRM_Core_Action
::
NONE
,
NULL
,
FALSE
,
'advanced'
);
$queryObject
=
$selector
->
getQueryObject
();
$sql
=
$queryObject
->
query
(
FALSE
,
FALSE
,
FALSE
,
$isDeleted
);
// Run the search
$rows
=
CRM_Core_DAO
::
executeQuery
(
implode
(
' '
,
$sql
))
->
fetchAll
();
// Check expected results.
$this
->
assertCount
(
1
,
$rows
);
$this
->
assertEquals
(
'John'
,
$rows
[
0
][
'first_name'
]);
$this
->
assertEquals
(
'Smith'
,
$rows
[
0
][
'last_name'
]);
}
}
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