-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Add / make fit for purpose email.getlist api call #16993
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,27 @@ | |
*/ | ||
class CRM_Contact_Form_Task_EmailCommonTest extends CiviUnitTestCase { | ||
|
||
/** | ||
* Set up for tests. | ||
* | ||
* @throws \CRM_Core_Exception | ||
*/ | ||
protected function setUp() { | ||
parent::setUp(); | ||
$this->_contactIds = [ | ||
$this->individualCreate(['first_name' => 'Antonia', 'last_name' => 'D`souza']), | ||
$this->individualCreate(['first_name' => 'Anthony', 'last_name' => 'Collins']), | ||
]; | ||
$this->_optionValue = $this->callApiSuccess('optionValue', 'create', [ | ||
$this->_optionValue = $this->callAPISuccess('optionValue', 'create', [ | ||
'label' => '"Seamus Lee" <[email protected]>', | ||
'option_group_id' => 'from_email_address', | ||
]); | ||
} | ||
|
||
/** | ||
* Test generating domain emails | ||
* | ||
* @throws \CRM_Core_Exception | ||
*/ | ||
public function testDomainEmailGeneration() { | ||
$emails = CRM_Core_BAO_Email::domainEmails(); | ||
|
@@ -39,6 +46,13 @@ public function testDomainEmailGeneration() { | |
$this->assertEquals('"Seamus Lee" <[email protected]>', $optionValue['values'][$this->_optionValue['id']]['label']); | ||
} | ||
|
||
/** | ||
* Test email uses signature. | ||
* | ||
* @throws \CRM_Core_Exception | ||
* @throws \CiviCRM_API3_Exception | ||
* @throws \Civi\API\Exception\UnauthorizedException | ||
*/ | ||
public function testPostProcessWithSignature() { | ||
$mut = new CiviMailUtils($this, TRUE); | ||
Civi::settings()->set('allow_mail_from_logged_in_contact', 1); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -495,4 +495,26 @@ public function testSetBulkEmail() { | |
$this->assertEquals(1, $emails[$email2['id']]['is_bulkmail']); | ||
} | ||
|
||
/** | ||
* Test getlist. | ||
* | ||
* @throws \CRM_Core_Exception | ||
*/ | ||
public function testGetlist() { | ||
$name = 'Scarabée'; | ||
$emailMatchContactID = $this->individualCreate(['last_name' => $name, 'email' => '[email protected]']); | ||
$emailMatchEmailID = $this->callAPISuccessGetValue('Email', ['return' => 'id', 'contact_id' => $emailMatchContactID]); | ||
$this->individualCreate(['last_name' => $name, 'email' => '[email protected]', 'is_deceased' => 1]); | ||
$this->individualCreate(['last_name' => $name, 'email' => '[email protected]', 'is_deleted' => 1]); | ||
$this->individualCreate(['last_name' => $name, 'api.email.create' => ['email' => '[email protected]', 'on_hold' => 1]]); | ||
$this->individualCreate(['last_name' => $name, 'do_not_email' => 1, 'api.email.create' => ['email' => '[email protected]']]); | ||
$nameMatchContactID = $this->individualCreate(['last_name' => 'bob', 'email' => '[email protected]']); | ||
$nameMatchEmailID = $this->callAPISuccessGetValue('Email', ['return' => 'id', 'contact_id' => $nameMatchContactID]); | ||
// We should get only the active live email-able contact. | ||
$result = $this->callAPISuccess('Email', 'getlist', ['input' => 'bob'])['values']; | ||
$this->assertCount(2, $result); | ||
$this->assertEquals($nameMatchEmailID, $result[0]['id']); | ||
$this->assertEquals($emailMatchEmailID, $result[1]['id']); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add something to the params here that excludes the original results.
NOT IN(array_keys($results))
would work partially, but it would only exclude the current page.What about a "NOT LIKE" clause to exclude any results that would have been returned by searching on the original field.
The reason I bring this up is because we are dealing with a paging situation so duplicate results can mess up the pager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colemanw - that makes sense. In my testing it had no negative performance impact adding that - however my testing did demonstrate that the way it was doing the ordering WAS having a performance impact and that for this to perform well the sort_field needs to be the same as the filter field. I'm on the fence about doing a post-sort in php - as of now its
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton this is looking really good. My one hesitation is that the
'NOT IN'
approach will possibly return redundant results because of the pager. Ex:$request
. It then fires the fallback request, using'NOT IN'
to exclude the 5 current results.If it's not a big performance hit, the
'NOT LIKE'
method could fix this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it was OK in the performance tests below so trying it