Skip to content

Commit

Permalink
Merge pull request #30 from PhantPHP/email-name-optional
Browse files Browse the repository at this point in the history
Email optional name
  • Loading branch information
lennyrouanet authored Mar 19, 2024
2 parents 58afb59 + 797be88 commit f51cd4e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion component/Time/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions component/Web/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions test/Web/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
'<p>Message</p>',
'[email protected]',
null,
'[email protected]',
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('<p>Message</p>', $email->messageHtml);

$this->assertIsObject($email->from);
$this->assertInstanceOf(EmailAddressAndName::class, $email->from);
$this->assertEquals('[email protected]', (string)$email->from->emailAddress);
$this->assertNull($email->from->name);

$this->assertIsObject($email->to);
$this->assertInstanceOf(EmailAddressAndName::class, $email->to);
$this->assertEquals('[email protected]', (string)$email->to->emailAddress);
$this->assertNull($email->to->name);

$this->assertNull($email->replyTo);

$this->assertNull($email->attachmentList);
}
}

0 comments on commit f51cd4e

Please sign in to comment.