From 8f8c11ad4e50a6008a9953720b69ca65f90c8d14 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 17 Apr 2025 10:32:49 +0200 Subject: [PATCH] fix(mail): use matching text color for primary elements when we use the default primary as background color we have to use the default primary text color as well. Signed-off-by: Ferdinand Thiessen --- .../tests/Mailer/NewUserMailHelperTest.php | 48 ++++++++++++------- lib/private/Mail/EMailTemplate.php | 4 +- tests/lib/Mail/EMailTemplateTest.php | 24 +++++----- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php index 87ad301dee7..1a1fc20354b 100644 --- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php +++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php @@ -146,8 +146,12 @@ class NewUserMailHelperTest extends TestCase { ->method('getName') ->willReturn('TestCloud'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultColorPrimary') + ->willReturn('#00679e'); + $this->defaults + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $expectedHtmlBody = << -
+
@@ -260,13 +264,13 @@ class NewUserMailHelperTest extends TestCase {
- +
-
+
@@ -496,13 +504,13 @@ EOF;
-
- Set your password + + Set your password
@@ -382,8 +386,12 @@ EOF; ->method('getName') ->willReturn('TestCloud'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultColorPrimary') + ->willReturn('#00679e'); + $this->defaults + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $expectedHtmlBody = <<
- +
-
+
@@ -721,13 +733,13 @@ EOF;
-
- Go to TestCloud + + Go to TestCloud
@@ -622,8 +630,12 @@ EOF; ->method('getName') ->willReturn('TestCloud'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultColorPrimary') + ->willReturn('#00679e'); + $this->defaults + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $expectedHtmlBody = <<
- +
-
- Go to TestCloud + + Go to TestCloud
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index 2cb222fd137..1d19f00b0a1 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -523,7 +523,7 @@ EOF; $this->ensureBodyListClosed(); $color = $this->themingDefaults->getDefaultColorPrimary(); - $textColor = $this->themingDefaults->getTextColorPrimary(); + $textColor = $this->themingDefaults->getDefaultTextColorPrimary(); $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]); $this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL; @@ -554,7 +554,7 @@ EOF; } $color = $this->themingDefaults->getDefaultColorPrimary(); - $textColor = $this->themingDefaults->getTextColorPrimary(); + $textColor = $this->themingDefaults->getDefaultTextColorPrimary(); $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]); if ($plainText !== false) { diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php index 76b37d48ff3..4943024043c 100644 --- a/tests/lib/Mail/EMailTemplateTest.php +++ b/tests/lib/Mail/EMailTemplateTest.php @@ -47,7 +47,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateCustomFooter(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -59,8 +59,8 @@ class EMailTemplateTest extends TestCase { ->method('getName') ->willReturn('TestCloud'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) @@ -88,7 +88,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateDefaultFooter(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -104,8 +104,8 @@ class EMailTemplateTest extends TestCase { ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) @@ -131,7 +131,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateSingleButton(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -147,8 +147,8 @@ class EMailTemplateTest extends TestCase { ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) @@ -176,7 +176,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateAlternativePlainTexts(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -192,8 +192,8 @@ class EMailTemplateTest extends TestCase { ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once())