forked from zendframework/zendframework
/
HOnlineComAtom10Test.php
199 lines (173 loc) · 5.99 KB
/
HOnlineComAtom10Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace ZendTest\Feed\Reader\Integration;
use Zend\Feed\Reader;
/**
* @group Zend_Feed
* @group Zend_Feed_Reader
*/
class HOnlineComAtom10Test extends \PHPUnit_Framework_TestCase
{
protected $feedSamplePath = null;
public function setup()
{
Reader\Reader::reset();
$this->feedSamplePath = dirname(__FILE__) . '/_files/h-online.com-atom10.xml';
}
public function testGetsTitle()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals('The H - news feed', $feed->getTitle());
}
public function testGetsAuthors()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals(array(array('name'=>'The H')), (array) $feed->getAuthors());
}
public function testGetsSingleAuthor()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals(array('name'=>'The H'), $feed->getAuthor());
}
public function testGetsCopyright()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals(null, $feed->getCopyright());
}
public function testGetsDescription()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals('Technology news', $feed->getDescription());
}
public function testGetsLanguage()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals(null, $feed->getLanguage());
}
public function testGetsLink()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals('http://www.h-online.com', $feed->getLink());
}
public function testGetsEncoding()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals('UTF-8', $feed->getEncoding());
}
public function testGetsEntryCount()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$this->assertEquals(60, $feed->count());
}
/**
* Entry level testing
*/
public function testGetsEntryId()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss', $entry->getId());
}
public function testGetsEntryTitle()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals('McAfee update brings systems down again', $entry->getTitle());
}
public function testGetsEntryAuthors()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals(array(array('name'=>'The H')), (array) $entry->getAuthors());
}
public function testGetsEntrySingleAuthor()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals(array('name'=>'The H'), $entry->getAuthor());
}
public function testGetsEntryDescription()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
/**
* Note: "’" is not the same as "'" - don't replace in error
*/
$this->assertEquals('A McAfee signature update is currently causing system failures and a lot of overtime for administrators', $entry->getDescription());
}
public function testGetsEntryContent()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals('A McAfee signature update is currently causing system failures and a lot of overtime for administrators', $entry->getContent());
}
public function testGetsEntryLinks()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals(array('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss'), $entry->getLinks());
}
public function testGetsEntryLink()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss', $entry->getLink());
}
public function testGetsEntryPermaLink()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss',
$entry->getPermaLink());
}
public function testGetsEntryEncoding()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath)
);
$entry = $feed->current();
$this->assertEquals('UTF-8', $entry->getEncoding());
}
}