Skip to content
Snippets Groups Projects
Commit dcfa013b authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

ISAICP-9186: Test coverage.

parent 75a83fa7
No related branches found
No related tags found
1 merge request!192ISAICP-9186: Error sending email on cron
...@@ -10,10 +10,12 @@ Feature: Subscribing to community content in collections ...@@ -10,10 +10,12 @@ Feature: Subscribing to community content in collections
| Products of Bulgaria | published | | Products of Bulgaria | published |
| Cities of Bulgaria | published | | Cities of Bulgaria | published |
And users: And users:
| Username | E-mail | First name | Family name | Notification frequency | | Username | E-mail | First name | Family name | Notification frequency | Status |
| hristo | hristo@example.bg | Hristo | Draganov | daily | | hristo | hristo@example.bg | Hristo | Draganov | daily | active |
| bisera | bisera@example.bg | Bisera | Kaloyancheva | weekly | | bisera | bisera@example.bg | Bisera | Kaloyancheva | weekly | active |
| kalin | kalin@primer.bg | Kalin | Antov | monthly | | kalin | kalin@primer.bg | Kalin | Antov | monthly | active |
| aleks | aleks@primer.bg | Aleksandar | Begov | monthly | blocked |
| penka | penka@primer.bg | Penka | Ramil | monthly | cancelled |
And the following collection user memberships: And the following collection user memberships:
| collection | user | roles | | collection | user | roles |
| Products of Bulgaria | hristo | | | Products of Bulgaria | hristo | |
...@@ -22,6 +24,8 @@ Feature: Subscribing to community content in collections ...@@ -22,6 +24,8 @@ Feature: Subscribing to community content in collections
| Cities of Bulgaria | hristo | | | Cities of Bulgaria | hristo | |
| Cities of Bulgaria | bisera | | | Cities of Bulgaria | bisera | |
| Cities of Bulgaria | kalin | facilitator | | Cities of Bulgaria | kalin | facilitator |
| Cities of Bulgaria | aleks | |
| Cities of Bulgaria | penka | |
And the following collection content subscriptions: And the following collection content subscriptions:
| collection | user | subscriptions | | collection | user | subscriptions |
| Products of Bulgaria | hristo | discussion, event, news, solution | | Products of Bulgaria | hristo | discussion, event, news, solution |
...@@ -30,10 +34,15 @@ Feature: Subscribing to community content in collections ...@@ -30,10 +34,15 @@ Feature: Subscribing to community content in collections
| Cities of Bulgaria | hristo | document, event, solution | | Cities of Bulgaria | hristo | document, event, solution |
| Cities of Bulgaria | bisera | discussion, event, news | | Cities of Bulgaria | bisera | discussion, event, news |
| Cities of Bulgaria | kalin | discussion, document, news, solution | | Cities of Bulgaria | kalin | discussion, document, news, solution |
| Cities of Bulgaria | aleks | discussion, document, news |
| Cities of Bulgaria | penka | discussion, document, news |
And all message digests have been delivered And all message digests have been delivered
Scenario: Receive a digest of content that is published in my collections Scenario: Receive a digest of content that is published in my collections
Given discussion content: # Start on clean.
Given I mark all emails as read
And discussion content:
| title | body | collection | state | author | | title | body | collection | state | author |
| Duck liver | Rich buttery and delicate | Products of Bulgaria | published | hristo | | Duck liver | Rich buttery and delicate | Products of Bulgaria | published | hristo |
| Sofia | Grows without aging | Cities of Bulgaria | published | kalin | | Sofia | Grows without aging | Cities of Bulgaria | published | kalin |
...@@ -143,6 +152,9 @@ Feature: Subscribing to community content in collections ...@@ -143,6 +152,9 @@ Feature: Subscribing to community content in collections
| Sunflower seeds | | Sunflower seeds |
And the content subscription digest sent to kalin should have the subject "Joinup: Monthly digest message" And the content subscription digest sent to kalin should have the subject "Joinup: Monthly digest message"
# No message for aleks@primer.bg (blocked) and penka@primer.bg (cancelled).
And 4 e-mails should have been sent to recipients "kalin@primer.bg, hristo@example.bg, bisera@example.bg"
# Clean out the message queue for the next test. # Clean out the message queue for the next test.
And I mark all emails as read And I mark all emails as read
......
...@@ -13,10 +13,13 @@ Feature: Subscribing to community content in solutions ...@@ -13,10 +13,13 @@ Feature: Subscribing to community content in solutions
| Products of Bulgaria | published | Bulgaria | | Products of Bulgaria | published | Bulgaria |
| Cities of Bulgaria | published | Bulgaria | | Cities of Bulgaria | published | Bulgaria |
And users: And users:
| Username | E-mail | First name | Family name | Notification frequency | | Username | E-mail | First name | Family name | Notification frequency | Status |
| hristo | hristo@example.bg | Hristo | Draganov | daily | | hristo | hristo@example.bg | Hristo | Draganov | daily | active |
| bisera | bisera@example.bg | Bisera | Kaloyancheva | weekly | | bisera | bisera@example.bg | Bisera | Kaloyancheva | weekly | active |
| kalin | kalin@primer.bg | Kalin | Antov | monthly | | kalin | kalin@primer.bg | Kalin | Antov | monthly | active |
| aleks | aleks@primer.bg | Aleksandar | Begov | monthly | blocked |
| penka | penka@primer.bg | Penka | Ramil | monthly | cancelled |
And the following solution user memberships: And the following solution user memberships:
| solution | user | roles | | solution | user | roles |
| Products of Bulgaria | hristo | | | Products of Bulgaria | hristo | |
...@@ -25,6 +28,8 @@ Feature: Subscribing to community content in solutions ...@@ -25,6 +28,8 @@ Feature: Subscribing to community content in solutions
| Cities of Bulgaria | hristo | | | Cities of Bulgaria | hristo | |
| Cities of Bulgaria | bisera | | | Cities of Bulgaria | bisera | |
| Cities of Bulgaria | kalin | facilitator | | Cities of Bulgaria | kalin | facilitator |
| Cities of Bulgaria | aleks | |
| Cities of Bulgaria | penka | |
And the following solution content subscriptions: And the following solution content subscriptions:
| solution | user | subscriptions | | solution | user | subscriptions |
| Products of Bulgaria | hristo | discussion, event, news, distribution | | Products of Bulgaria | hristo | discussion, event, news, distribution |
...@@ -33,10 +38,15 @@ Feature: Subscribing to community content in solutions ...@@ -33,10 +38,15 @@ Feature: Subscribing to community content in solutions
| Cities of Bulgaria | hristo | document, event | | Cities of Bulgaria | hristo | document, event |
| Cities of Bulgaria | bisera | discussion, event, news | | Cities of Bulgaria | bisera | discussion, event, news |
| Cities of Bulgaria | kalin | discussion, document, news | | Cities of Bulgaria | kalin | discussion, document, news |
| Cities of Bulgaria | aleks | discussion, document, news |
| Cities of Bulgaria | penka | discussion, document, news |
And all message digests have been delivered And all message digests have been delivered
Scenario: Receive a digest of content that is published in my solutions Scenario: Receive a digest of content that is published in my solutions
Given discussion content: # Start on clean.
Given I mark all emails as read
And discussion content:
| title | body | solution | state | author | | title | body | solution | state | author |
| Duck liver | Rich buttery and delicate | Products of Bulgaria | published | hristo | | Duck liver | Rich buttery and delicate | Products of Bulgaria | published | hristo |
| Sofia | Grows without aging | Cities of Bulgaria | published | kalin | | Sofia | Grows without aging | Cities of Bulgaria | published | kalin |
...@@ -159,6 +169,9 @@ Feature: Subscribing to community content in solutions ...@@ -159,6 +169,9 @@ Feature: Subscribing to community content in solutions
| Sunflower seeds | | Sunflower seeds |
And the content subscription digest sent to kalin should have the subject "Joinup: Monthly digest message" And the content subscription digest sent to kalin should have the subject "Joinup: Monthly digest message"
# No message for aleks@primer.bg (blocked) and penka@primer.bg (cancelled).
And 4 e-mails should have been sent to recipients "kalin@primer.bg, hristo@example.bg, bisera@example.bg"
# Clean out the message queue for the next test. # Clean out the message queue for the next test.
And I mark all emails as read And I mark all emails as read
......
...@@ -364,17 +364,32 @@ public function clearMailCollectorCache(): void { ...@@ -364,17 +364,32 @@ public function clearMailCollectorCache(): void {
* *
* @param int $count * @param int $count
* The expected count of e-mails sent. * The expected count of e-mails sent.
* @param string|null $recipients
* (optional) A list of recipient emails.
* *
* @throws \Exception * @throws \Exception
* Thrown when the count doesn't match the actual number. * Thrown when the count doesn't match the actual number.
* *
* @Then :count e-mail(s) should have been sent * @Then :count e-mail(s) should have been sent
* @Then :count e-mail(s) should have been sent to recipients :recipients
*/ */
public function assertNumberOfEmailSent($count): void { public function assertNumberOfEmailSent(int $count, ?string $recipients = NULL): void {
$mails = $this->getMails(); $mails = $this->getMails();
if (count($mails) != $count) { if (count($mails) != $count) {
throw new \Exception("Invalid number of e-mail sent. Expected $count, sent " . count($mails)); throw new \Exception("Invalid number of e-mail sent. Expected $count, sent " . count($mails));
} }
if ($recipients) {
$expected_recipients = $this->explodeCommaSeparatedStepArgument($recipients);
$actual_recipients = array_unique(array_map(
fn(array $mail): string => $mail['to'],
$mails,
));
sort($expected_recipients);
sort($actual_recipients);
if ($expected_recipients !== $actual_recipients) {
throw new ExpectationFailedException("Expected recipients $recipients. Got " . implode(', ', $actual_recipients));
}
}
} }
/** /**
......
...@@ -156,6 +156,7 @@ public static function massageFieldsBeforeUserCreate(BeforeUserCreateScope $scop ...@@ -156,6 +156,7 @@ public static function massageFieldsBeforeUserCreate(BeforeUserCreateScope $scop
self::convertObjectPropertyValues($user, 'status', [ self::convertObjectPropertyValues($user, 'status', [
'blocked' => 0, 'blocked' => 0,
'active' => 1, 'active' => 1,
'cancelled' => -1,
]); ]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment