Skip to content
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

CRM-17629 - JobProcessMailingTest - Test w/mailerBatchLimit & 2x mailings #7587

Merged
merged 1 commit into from
May 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions tests/phpunit/api/v3/JobProcessMailingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function setUp() {
'scheduled_date' => 'now',
);
$this->defaultSettings = array(
'mailings' => 1, // int, #mailings to send
'recipients' => 20, // int, #contacts to receive mailing
'workers' => 1, // int, #concurrent cron jobs
'iterations' => 1, // int, #times to spawn all the workers
Expand Down Expand Up @@ -212,6 +213,24 @@ public function concurrencyExamples() {
10, // Total sent.
);

// For two mailings, launch 1 worker, 5 times in a row. Deliver everything.
$es[6] = array(
array(// Settings.
'mailings' => 2,
'recipients' => 10,
'workers' => 1,
'iterations' => 5,
'mailerBatchLimit' => 6,
),
array(// Tallies.
// x6 => x4+x2 => x6 => x2 => x0
6 => 3, // 3 jobs which produce 6 messages
2 => 1, // 1 job which produces 2 messages
0 => 1, // 1 job which produces 0 messages
),
20, // Total sent.
);

return $es;
}

Expand Down Expand Up @@ -244,7 +263,9 @@ public function testConcurrency($settings, $expectedTallies, $expectedTotal) {
'mailThrottleTime',
)));

$this->callAPISuccess('mailing', 'create', $this->_params);
for ($i = 0; $i < $settings['mailings']; $i++) {
$this->callAPISuccess('mailing', 'create', $this->_params);
}

$this->_mut->assertRecipients(array());

Expand All @@ -268,7 +289,7 @@ public function testConcurrency($settings, $expectedTallies, $expectedTotal) {
'actualTallies' => $actualTallies,
'apiResults' => $allApiResults,
), TRUE));
$this->_mut->assertRecipients($this->getRecipients(1, $expectedTotal));
$this->_mut->assertRecipients($this->getRecipients(1, $expectedTotal / $settings['mailings'], 'nul.example.com', $settings['mailings']));
$this->assertEquals(0, $apiCalls->getRunningCount());
}

Expand All @@ -295,13 +316,17 @@ public function createContactsInGroup($count, $groupID, $domain = 'nul.example.c
*
* @param int $start
* @param int $count
* @param string $domain
* @param int $mailings
*
* @return array
*/
public function getRecipients($start, $count, $domain = 'nul.example.com') {
public function getRecipients($start, $count, $domain = 'nul.example.com', $mailings = 1) {
$recipients = array();
for ($i = $start; $i < ($start + $count); $i++) {
$recipients[][0] = 'mail' . $i . '@' . $domain;
for ($m = 0; $m < $mailings; $m++) {
for ($i = $start; $i < ($start + $count); $i++) {
$recipients[][0] = 'mail' . $i . '@' . $domain;
}
}
return $recipients;
}
Expand Down