forked from kodus/mail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking change to improve message date handling
- Loading branch information
1 parent
e8f5e15
commit 4684bdd
Showing
8 changed files
with
90 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
filter: | ||
paths: [src/*] | ||
|
||
tools: | ||
external_code_coverage: true | ||
php_mess_detector: true | ||
php_code_sniffer: true | ||
php_pdepend: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
UPGRADING | ||
========= | ||
|
||
## 0.1.x to 0.2.x | ||
|
||
`Message::getDate()` now returns `DateTimeInterface` - it previously returned a UNIX (integer) timestamp. | ||
|
||
`Message::setDate()` still accepts UNIX timestamps and strings, and now also `DateTime` and `DateTimeImmutable`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
namespace Kodus\Mail\Test\Unit; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use InvalidArgumentException; | ||
use Kodus\Mail\Address; | ||
use Kodus\Mail\Header; | ||
|
@@ -63,4 +65,52 @@ function () use ($message) { | |
} | ||
); | ||
} | ||
|
||
public function setDate(UnitTester $I) | ||
{ | ||
$message = new Message( | ||
new Address("[email protected]"), | ||
new Address("[email protected]"), | ||
"Hello, Bob", | ||
null | ||
); | ||
|
||
// try setting a Date from a string in two different system timezones: | ||
|
||
date_default_timezone_set("Europe/Copenhagen"); | ||
|
||
$message->setDate("Thu, 15 Sep 2016 17:20:54"); | ||
|
||
$I->assertSame("Thu, 15 Sep 2016 17:20:54 +0200", $message->getDate()->format("r")); | ||
|
||
date_default_timezone_set("UTC"); | ||
|
||
$message->setDate("Thu, 15 Sep 2016 17:20:54"); | ||
|
||
$I->assertSame("Thu, 15 Sep 2016 17:20:54 +0000", $message->getDate()->format("r")); | ||
|
||
// try setting a Date from an UNIX timestamp in two different system timezones: | ||
|
||
date_default_timezone_set("Europe/Copenhagen"); | ||
|
||
$message->setDate(1473952854); | ||
|
||
$I->assertSame("Thu, 15 Sep 2016 17:20:54 +0200", $message->getDate()->format("r")); | ||
|
||
date_default_timezone_set("UTC"); | ||
|
||
$message->setDate(1473952854); | ||
|
||
$I->assertSame("Thu, 15 Sep 2016 15:20:54 +0000", $message->getDate()->format("r")); | ||
|
||
// try setting a Date from a DateTime instance: | ||
|
||
$date = new DateTime("@" . strtotime("Thu, 15 Sep 2016 17:20:54 +0200")); | ||
|
||
$date->setTimezone(new DateTimeZone("Europe/Copenhagen")); | ||
|
||
$message->setDate($date); | ||
|
||
$I->assertSame("Thu, 15 Sep 2016 17:20:54 +0200", $message->getDate()->format("r")); | ||
} | ||
} |