|
4 | 4 |
|
5 | 5 | use DateTime; |
6 | 6 | use JDecool\JsonFeed\Attachment; |
| 7 | +use JDecool\JsonFeed\Author; |
7 | 8 | use JDecool\JsonFeed\Item; |
8 | 9 | use JDecool\JsonFeed\Reader\Version1\FeedReader; |
9 | 10 | use PHPUnit\Framework\TestCase; |
@@ -94,6 +95,37 @@ public function testMicroblogFeed() |
94 | 95 | $this->assertEquals($item, $items[0]); |
95 | 96 | } |
96 | 97 |
|
| 98 | + public function testAuthorsFeed() |
| 99 | + { |
| 100 | + $input = $this->getFixtures('authors'); |
| 101 | + $reader = FeedReader::create(); |
| 102 | + |
| 103 | + $feed = $reader->readFromJson($input); |
| 104 | + $this->assertInstanceOf('JDecool\JsonFeed\Feed', $feed); |
| 105 | + $this->assertEquals('My Example Feed', $feed->getTitle()); |
| 106 | + $this->assertEquals('Global Author', $feed->getAuthor()->getName()); |
| 107 | + $this->assertEquals('https://example.org/feed.json', $feed->getFeedUrl()); |
| 108 | + |
| 109 | + $items = $feed->getItems(); |
| 110 | + $this->assertCount(2, $items); |
| 111 | + |
| 112 | + $item2Author = new Author('Author 2'); |
| 113 | + $item2 = new Item('2'); |
| 114 | + $item2->setUrl('https://example.org/2'); |
| 115 | + $item2->setContentText('This is a second item.'); |
| 116 | + $item2->setAuthor($item2Author); |
| 117 | + $this->assertEquals('Author 2', $item2->getAuthor()->getName()); |
| 118 | + $this->assertEquals($item2, $items[0]); |
| 119 | + |
| 120 | + $item1Author = new Author('Author 1'); |
| 121 | + $item1 = new Item('1'); |
| 122 | + $item1->setUrl('https://example.org/1'); |
| 123 | + $item1->setContentHtml('<p>This is the first item.</p>'); |
| 124 | + $item1->setAuthor($item1Author); |
| 125 | + $this->assertEquals('Author 1', $item1->getAuthor()->getName()); |
| 126 | + $this->assertEquals($item1, $items[1]); |
| 127 | + } |
| 128 | + |
97 | 129 | /** |
98 | 130 | * @expectedException JDecool\JsonFeed\Exceptions\InvalidFeedException |
99 | 131 | * @expectedExceptionMessage Invalid JSONFeed string |
|
0 commit comments