Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class EmailProviderTest extends AbstractNotificationProviderTestCase {
public const USER_EMAIL = 'frodo@hobb.it';
private IMailer&MockObject $mailer;

/** @var list<string> order of the note and details blocks across all templates */
private array $blockOrder = [];

protected function setUp(): void {
parent::setUp();

Expand Down Expand Up @@ -123,6 +126,8 @@ public function testSendWithoutAttendees():void {

$vcalendar = $this->getNoAttendeeVCalendar();
$this->provider->send($vcalendar->VEVENT, $this->calendarDisplayName, $principalEmailAddresses, $users);

$this->assertSame(['details', 'note', 'details', 'note'], $this->blockOrder);
}

public function testSendWithAttendeesWhenOwnerIsOrganizer(): void {
Expand Down Expand Up @@ -320,11 +325,17 @@ private function getTemplateMock():IEMailTemplate {
['When', ['weekdayName, datetime - time (UTC)']],
['Where', ['Location 123']],
];
}));
}))
->willReturnCallback(function (): void {
$this->blockOrder[] = 'details';
});

$template->expects($this->once())
->method('addBodyNote')
->with('DESCRIPTION 456', 'Description');
->with('DESCRIPTION 456', 'Description')
->willReturnCallback(function (): void {
$this->blockOrder[] = 'note';
});

$template->expects($this->once())
->method('addFooter')
Expand Down
25 changes: 25 additions & 0 deletions apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,31 @@ private static function rowsOf(EMailDetails $details): array {
);
}

public function testAddEventDetailsPutsDescriptionAfterCard(): void {
$this->mockDetailsL10n();
$this->appConfig->method('getValueBool')->willReturn(false);
$template = $this->createMock(IEMailTemplate::class);
$order = [];
$template->method('addBodyNote')->willReturnCallback(function (string $text, string $label) use (&$order): void {
$order[] = 'note:' . $label;
});
$template->method('addBodyDetails')->willReturnCallback(function () use (&$order): void {
$order[] = 'details';
});

$this->service->addEventDetails($template, $this->createDetailsEvent(), [
'meeting_title' => 'Title',
'meeting_when' => 'Monday',
'meeting_location' => '',
'meeting_url' => '',
'meeting_description' => 'New description',
'meeting_description_previous' => 'Old description',
'meeting_occurring' => '',
]);

$this->assertSame(['details', 'note:Description', 'note:Previous description'], $order);
}

public function testAddEventDetails(): void {
$this->mockDetailsL10n();
$this->appConfig->method('getValueBool')->willReturn(false);
Expand Down
13 changes: 11 additions & 2 deletions apps/settings/tests/HooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public function testPasswordChangedMail(): void {

public function testEmailChangedMail(): void {
$this->user->method('getEMailAddress')->willReturn('new@example.com');
$order = [];

$this->template->expects($this->once())->method('addBodyText')
->with('Your email address on https://cloud.example.com/ was changed.');
Expand All @@ -102,12 +103,20 @@ public function testEmailChangedMail(): void {
['Previous email address', [[EMailDetailsRow::PART_TEXT, 'old@example.com']]],
['New email address', [[EMailDetailsRow::PART_TEXT, 'new@example.com']]],
],
]));
]))
->willReturnCallback(function () use (&$order): void {
$order[] = 'details';
});
$this->template->expects($this->once())->method('addBodyNote')
->with('If you did not request this, please contact an administrator.', '', IEMailTemplate::NOTE_WARNING);
->with('If you did not request this, please contact an administrator.', '', IEMailTemplate::NOTE_WARNING)
->willReturnCallback(function () use (&$order): void {
$order[] = 'note';
});
$this->mailer->expects($this->once())->method('send');

$this->hooks->handle(new UserChangedEvent($this->user, 'eMailAddress', 'new@example.com', 'old@example.com'));

$this->assertSame(['details', 'note'], $order);
}

public function testEmailRemovedMail(): void {
Expand Down
9 changes: 6 additions & 3 deletions apps/settings/tests/Mailer/NewUserMailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public function testGenerateTemplateWithPasswordResetToken(): void {
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -181,7 +182,7 @@ public function testGenerateTemplateWithPasswordResetToken(): void {
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#00679e;padding:24px 36px">
<img class="logo" src="" alt="TestCloud" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down Expand Up @@ -277,6 +278,7 @@ public function testGenerateTemplateWithoutPasswordResetToken(): void {
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -298,7 +300,7 @@ public function testGenerateTemplateWithoutPasswordResetToken(): void {
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#00679e;padding:24px 36px">
<img class="logo" src="" alt="TestCloud" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down Expand Up @@ -398,6 +400,7 @@ public function testGenerateTemplateWithoutUserId(): void {
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -419,7 +422,7 @@ public function testGenerateTemplateWithoutUserId(): void {
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#00679e;padding:24px 36px">
<img class="logo" src="" alt="TestCloud" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Mail/EMailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class EMailTemplate implements IEMailTemplate {
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -75,7 +76,7 @@ class EMailTemplate implements IEMailTemplate {
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px">
EOF;

Expand Down
3 changes: 2 additions & 1 deletion lib/public/Mail/IEMailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public function addBodySender(string $displayName, string $subline = ''): void;
*
* Use {@see self::NOTE_NEUTRAL} for content written by a user (share note,
* event description), the other types for messages from the server itself.
* Line breaks in $text are kept.
* Line breaks in $text are kept. A short note about a shared item goes
* before its details card, longer content like an event description after it.
*
* @param string $label Label above the text for neutral notes, bold title before it for the other types
* @param self::NOTE_* $type
Expand Down
3 changes: 2 additions & 1 deletion tests/data/emails/blocks-email.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -31,7 +32,7 @@
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#0082c9;padding:24px 36px">
<img class="logo" src="https://example.org/img/logo-mail-header.png" alt="TestCloud" width="252" height="120" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down
3 changes: 2 additions & 1 deletion tests/data/emails/new-account-email-custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -31,7 +32,7 @@
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#0082c9;padding:24px 36px">
<img class="logo" src="https://example.org/img/logo-mail-header.png" alt="TestCloud" width="252" height="120" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down
3 changes: 2 additions & 1 deletion tests/data/emails/new-account-email-single-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -31,7 +32,7 @@
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#0082c9;padding:24px 36px">
<img class="logo" src="https://example.org/img/logo-mail-header.png" alt="TestCloud" width="252" height="120" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down
3 changes: 2 additions & 1 deletion tests/data/emails/new-account-email.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:root{color-scheme:light dark;supported-color-schemes:light dark}
body{margin:0;padding:0;width:100%!important}
@media only screen and (max-width:640px){
.nc-page-pad{padding:0!important}
.nc-card{border-radius:0!important;width:100%!important}
.nc-pad{padding-left:20px!important;padding-right:20px!important}
.nc-button{display:block!important;margin:0 0 12px 0!important}
Expand All @@ -31,7 +32,7 @@
<body class="nc-page" style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f4f4f5;box-sizing:border-box;margin:0;min-width:100%;padding:0;width:100%!important">
<table role="presentation" class="nc-page" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;border-collapse:collapse;border-spacing:0;width:100%">
<tr>
<td align="center" style="padding:32px 0">
<td class="nc-page-pad" align="center" style="padding:32px 0">
<table role="presentation" class="nc-card" width="600" cellpadding="0" cellspacing="0" style="background:#ffffff;border-collapse:separate;border-radius:16px;border-spacing:0;max-width:600px;overflow:hidden;text-align:left;width:600px"> <tr>
<td class="nc-pad" style="background:#0082c9;padding:24px 36px">
<img class="logo" src="https://example.org/img/logo-mail-header.png" alt="TestCloud" width="252" height="120" style="-ms-interpolation-mode:bicubic;border:none;display:block;max-height:48px;max-width:200px;outline:0;text-decoration:none;width:auto">
Expand Down
Loading