1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2017 Ryan Parman <http://ryanparman.com>. |
4
|
|
|
* Copyright (c) 2017 Contributors. |
5
|
|
|
* |
6
|
|
|
* http://opensource.org/licenses/Apache2.0 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace SimplePie\Test\Integration\Atom\Feed; |
12
|
|
|
|
13
|
|
|
use DateTime; |
14
|
|
|
use DateTimeZone; |
15
|
|
|
use SimplePie\Enum\DateFormat; |
16
|
|
|
use SimplePie\Test\Integration\AbstractTestCase; |
17
|
|
|
use Skyzyx\UtilityPack\Types; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @coversNothing |
21
|
|
|
*/ |
22
|
|
|
class PublishedUpdatedTest extends AbstractTestCase |
23
|
|
|
{ |
24
|
|
|
public function testPublished(): void |
25
|
|
|
{ |
26
|
|
|
$published = $this->feed->getPublished(); |
27
|
|
|
|
28
|
|
|
$this->assertEquals(DateTime::class, Types::getClassOrType($published)); |
29
|
|
|
$this->assertEquals(1456518612, $published->getTimestamp()); |
30
|
|
|
$this->assertEquals(0, $published->getOffset()); |
31
|
|
|
|
32
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::RFC3339)); |
33
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::ISO8601)); |
34
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::ATOM)); |
35
|
|
|
$this->assertEquals('Fri, 26 Feb 16 20:30:12 +0000', $published->format(DateFormat::RFC822)); |
36
|
|
|
$this->assertEquals('Fri, 26 Feb 2016 20:30:12 +0000', $published->format(DateFormat::RFC2822)); |
37
|
|
|
$this->assertEquals('Fri, 26 Feb 2016 20:30:12 +0000', $published->format(DateFormat::RSS20)); |
38
|
|
|
|
39
|
|
|
$this->assertEquals(DateTimeZone::class, Types::getClassOrType($published->getTimezone())); |
40
|
|
|
$this->assertEquals('Z', $published->getTimezone()->getName()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testPublishedAtom10(): void |
44
|
|
|
{ |
45
|
|
|
$published = $this->feed->getPublished('atom10'); |
46
|
|
|
|
47
|
|
|
$this->assertEquals(DateTime::class, Types::getClassOrType($published)); |
48
|
|
|
$this->assertEquals(1456518612, $published->getTimestamp()); |
49
|
|
|
$this->assertEquals(0, $published->getOffset()); |
50
|
|
|
|
51
|
|
|
$this->assertEquals(DateTimeZone::class, Types::getClassOrType($published->getTimezone())); |
52
|
|
|
$this->assertEquals('Z', $published->getTimezone()->getName()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testPublishedUsWestCoast(): void |
56
|
|
|
{ |
57
|
|
|
$published = $this->feed->getPublished()->setTimezone(new \DateTimeZone('America/Los_Angeles')); |
58
|
|
|
|
59
|
|
|
$this->assertEquals(1456518612, $published->getTimestamp()); |
60
|
|
|
$this->assertEquals(-28800, $published->getOffset()); |
61
|
|
|
|
62
|
|
|
$this->assertEquals(DateTimeZone::class, Types::getClassOrType($published->getTimezone())); |
63
|
|
|
$this->assertEquals('America/Los_Angeles', $published->getTimezone()->getName()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testPubDate(): void |
67
|
|
|
{ |
68
|
|
|
$published = $this->feed->getPubDate(); |
69
|
|
|
|
70
|
|
|
$this->assertEquals(DateTime::class, Types::getClassOrType($published)); |
71
|
|
|
$this->assertEquals(1456518612, $published->getTimestamp()); |
72
|
|
|
$this->assertEquals(0, $published->getOffset()); |
73
|
|
|
|
74
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::RFC3339)); |
75
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::ISO8601)); |
76
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::ATOM)); |
77
|
|
|
$this->assertEquals('Fri, 26 Feb 16 20:30:12 +0000', $published->format(DateFormat::RFC822)); |
78
|
|
|
$this->assertEquals('Fri, 26 Feb 2016 20:30:12 +0000', $published->format(DateFormat::RFC2822)); |
79
|
|
|
$this->assertEquals('Fri, 26 Feb 2016 20:30:12 +0000', $published->format(DateFormat::RSS20)); |
80
|
|
|
|
81
|
|
|
$this->assertEquals(DateTimeZone::class, Types::getClassOrType($published->getTimezone())); |
82
|
|
|
$this->assertEquals('Z', $published->getTimezone()->getName()); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function testUpdated(): void |
86
|
|
|
{ |
87
|
|
|
$published = $this->feed->getUpdated(); |
88
|
|
|
|
89
|
|
|
$this->assertEquals(DateTime::class, Types::getClassOrType($published)); |
90
|
|
|
$this->assertEquals(1456518612, $published->getTimestamp()); |
91
|
|
|
$this->assertEquals(0, $published->getOffset()); |
92
|
|
|
|
93
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::RFC3339)); |
94
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::ISO8601)); |
95
|
|
|
$this->assertEquals('2016-02-26T20:30:12+00:00', $published->format(DateFormat::ATOM)); |
96
|
|
|
$this->assertEquals('Fri, 26 Feb 16 20:30:12 +0000', $published->format(DateFormat::RFC822)); |
97
|
|
|
$this->assertEquals('Fri, 26 Feb 2016 20:30:12 +0000', $published->format(DateFormat::RFC2822)); |
98
|
|
|
$this->assertEquals('Fri, 26 Feb 2016 20:30:12 +0000', $published->format(DateFormat::RSS20)); |
99
|
|
|
|
100
|
|
|
$this->assertEquals(DateTimeZone::class, Types::getClassOrType($published->getTimezone())); |
101
|
|
|
$this->assertEquals('Z', $published->getTimezone()->getName()); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|