From 75e21ac0e52b8b09fc98d0577fe884e1d45c0e8b Mon Sep 17 00:00:00 2001 From: Lenny ROUANET Date: Tue, 19 Mar 2024 11:41:09 +0100 Subject: [PATCH 1/3] Email optional name --- component/Web/Email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component/Web/Email.php b/component/Web/Email.php index 6e03115..57740eb 100644 --- a/component/Web/Email.php +++ b/component/Web/Email.php @@ -25,9 +25,9 @@ public static function make( string $messageTxt, string $messageHtml, string $fromEmailAddress, - string $fromName, + ?string $fromName, string $toEmailAddress, - string $toName, + ?string $toName, ?string $replyToEmailAddress = null, ?string $replyToName = null, ?EmailAttachmentList $attachmentList = null From d5ebeade4b8b70263b42121787e44664afc7e75a Mon Sep 17 00:00:00 2001 From: Lenny ROUANET Date: Tue, 19 Mar 2024 11:47:25 +0100 Subject: [PATCH 2/3] Test --- test/Web/EmailTest.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/Web/EmailTest.php b/test/Web/EmailTest.php index 0f8624a..b2cd3e7 100644 --- a/test/Web/EmailTest.php +++ b/test/Web/EmailTest.php @@ -122,4 +122,42 @@ public function testMake(): void $this->assertIsObject($email->attachmentList); $this->assertInstanceOf(EmailAttachmentList::class, $email->attachmentList); } + + public function testMakeBasic(): void + { + $email = Email::make( + 'Subject', + 'Message', + '

Message

', + 'contact@acme.ext', + null, + 'john.doe@domain.ext', + null + ); + + $this->assertInstanceOf(Email::class, $email); + + $this->assertIsString($email->subject); + $this->assertEquals('Subject', $email->subject); + + $this->assertIsString($email->messageTxt); + $this->assertEquals('Message', $email->messageTxt); + + $this->assertIsString($email->messageHtml); + $this->assertEquals('

Message

', $email->messageHtml); + + $this->assertIsObject($email->from); + $this->assertInstanceOf(EmailAddressAndName::class, $email->from); + $this->assertEquals('contact@acme.ext', (string)$email->from->emailAddress); + $this->assertNull($email->from->name); + + $this->assertIsObject($email->to); + $this->assertInstanceOf(EmailAddressAndName::class, $email->to); + $this->assertEquals('john.doe@domain.ext', (string)$email->to->emailAddress); + $this->assertNull($email->to->name); + + $this->assertNull($email->replyTo); + + $this->assertNull($email->attachmentList); + } } From 797be8889d8a758ea80638721b34d4a2215e574e Mon Sep 17 00:00:00 2001 From: Lenny ROUANET Date: Tue, 19 Mar 2024 11:47:29 +0100 Subject: [PATCH 3/3] Fix date --- component/Time/Date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/Time/Date.php b/component/Time/Date.php index b116cbe..33cf93b 100644 --- a/component/Time/Date.php +++ b/component/Time/Date.php @@ -22,7 +22,7 @@ public function __construct( $time = is_string($date) ? strtotime($date) : $date; - if (!is_a($this, DateTime::class)) { + if (!is_a($this, DateTime::class) && $time) { $time = (new \DateTime())->setTimestamp($time)->setTime(0, 0)->getTimestamp(); }