Skip to content

Commit

Permalink
CATL-1614: Add unit test to test is_contact_creation_disabled_if_no_m…
Browse files Browse the repository at this point in the history
…atch option during Inbound Email Processing
  • Loading branch information
i-grou committed Aug 20, 2020
1 parent 7f523b3 commit 86e1764
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,37 @@ public function setUpMailing() {
$this->eventQueue = $this->callAPISuccess('MailingEventQueue', 'get', ['api.MailingEventQueue.create' => ['hash' => 'aaaaaaaaaaaaaaaa']]);
}

/**
* Set up mail account with 'Do not create new contacts when filing emails'
* option enabled.
*/
public function setUpDoNotCreateContact() {
$this->callAPISuccess('MailSettings', 'get', [
'api.MailSettings.create' => [
'name' => 'mailbox',
'protocol' => 'Localdir',
'source' => __DIR__ . '/data/mail',
'domain' => 'example.com',
'is_default' => '0',
'is_contact_creation_disabled_if_no_match' => TRUE,
],
]);
}

/**
* Test case email processing when is_non_case_email_skipped is enabled.
*/
public function testInboundProcessingDoNotCreateContact() {
$this->setUpDoNotCreateContact();
$mail = 'test_non_cases_email.eml';

copy(__DIR__ . '/data/inbound/' . $mail, __DIR__ . '/data/mail/' . $mail);
$this->callAPISuccess('job', 'fetch_activities', []);
$result = civicrm_api3('Contact', 'get', [
'sequential' => 1,
'email' => "[email protected]",
]);
$this->assertTrue(empty($result['values']));
}

}

0 comments on commit 86e1764

Please sign in to comment.