aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/feed/FeedBuilderTest.php63
1 files changed, 15 insertions, 48 deletions
diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php
index 535207aa..b2b70b70 100644
--- a/tests/feed/FeedBuilderTest.php
+++ b/tests/feed/FeedBuilderTest.php
@@ -65,23 +65,6 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
65 } 65 }
66 66
67 /** 67 /**
68 * Test GetTypeLanguage().
69 */
70 public function testGetTypeLanguage()
71 {
72 $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_ATOM, null, null, false);
73 $feedBuilder->setLocale(self::$LOCALE);
74 $this->assertEquals(self::$ATOM_LANGUAGUE, $feedBuilder->getTypeLanguage());
75 $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_RSS, null, null, false);
76 $feedBuilder->setLocale(self::$LOCALE);
77 $this->assertEquals(self::$RSS_LANGUAGE, $feedBuilder->getTypeLanguage());
78 $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_ATOM, null, null, false);
79 $this->assertEquals('en', $feedBuilder->getTypeLanguage());
80 $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_RSS, null, null, false);
81 $this->assertEquals('en-en', $feedBuilder->getTypeLanguage());
82 }
83
84 /**
85 * Test buildData with RSS feed. 68 * Test buildData with RSS feed.
86 */ 69 */
87 public function testRSSBuildData() 70 public function testRSSBuildData()
@@ -89,13 +72,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
89 $feedBuilder = new FeedBuilder( 72 $feedBuilder = new FeedBuilder(
90 self::$bookmarkService, 73 self::$bookmarkService,
91 self::$formatter, 74 self::$formatter,
92 FeedBuilder::$FEED_RSS, 75 static::$serverInfo,
93 self::$serverInfo,
94 null,
95 false 76 false
96 ); 77 );
97 $feedBuilder->setLocale(self::$LOCALE); 78 $feedBuilder->setLocale(self::$LOCALE);
98 $data = $feedBuilder->buildData(); 79 $data = $feedBuilder->buildData(FeedBuilder::$FEED_RSS, null);
99 // Test headers (RSS) 80 // Test headers (RSS)
100 $this->assertEquals(self::$RSS_LANGUAGE, $data['language']); 81 $this->assertEquals(self::$RSS_LANGUAGE, $data['language']);
101 $this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']); 82 $this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']);
@@ -140,13 +121,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
140 $feedBuilder = new FeedBuilder( 121 $feedBuilder = new FeedBuilder(
141 self::$bookmarkService, 122 self::$bookmarkService,
142 self::$formatter, 123 self::$formatter,
143 FeedBuilder::$FEED_ATOM, 124 static::$serverInfo,
144 self::$serverInfo,
145 null,
146 false 125 false
147 ); 126 );
148 $feedBuilder->setLocale(self::$LOCALE); 127 $feedBuilder->setLocale(self::$LOCALE);
149 $data = $feedBuilder->buildData(); 128 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null);
150 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); 129 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links']));
151 $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['last_update']); 130 $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['last_update']);
152 $link = $data['links'][array_keys($data['links'])[2]]; 131 $link = $data['links'][array_keys($data['links'])[2]];
@@ -166,13 +145,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
166 $feedBuilder = new FeedBuilder( 145 $feedBuilder = new FeedBuilder(
167 self::$bookmarkService, 146 self::$bookmarkService,
168 self::$formatter, 147 self::$formatter,
169 FeedBuilder::$FEED_ATOM, 148 static::$serverInfo,
170 self::$serverInfo,
171 $criteria,
172 false 149 false
173 ); 150 );
174 $feedBuilder->setLocale(self::$LOCALE); 151 $feedBuilder->setLocale(self::$LOCALE);
175 $data = $feedBuilder->buildData(); 152 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, $criteria);
176 $this->assertEquals(1, count($data['links'])); 153 $this->assertEquals(1, count($data['links']));
177 $link = array_shift($data['links']); 154 $link = array_shift($data['links']);
178 $this->assertEquals(41, $link['id']); 155 $this->assertEquals(41, $link['id']);
@@ -190,13 +167,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
190 $feedBuilder = new FeedBuilder( 167 $feedBuilder = new FeedBuilder(
191 self::$bookmarkService, 168 self::$bookmarkService,
192 self::$formatter, 169 self::$formatter,
193 FeedBuilder::$FEED_ATOM, 170 static::$serverInfo,
194 self::$serverInfo,
195 $criteria,
196 false 171 false
197 ); 172 );
198 $feedBuilder->setLocale(self::$LOCALE); 173 $feedBuilder->setLocale(self::$LOCALE);
199 $data = $feedBuilder->buildData(); 174 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, $criteria);
200 $this->assertEquals(3, count($data['links'])); 175 $this->assertEquals(3, count($data['links']));
201 $link = $data['links'][array_keys($data['links'])[2]]; 176 $link = $data['links'][array_keys($data['links'])[2]];
202 $this->assertEquals(41, $link['id']); 177 $this->assertEquals(41, $link['id']);
@@ -211,14 +186,12 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
211 $feedBuilder = new FeedBuilder( 186 $feedBuilder = new FeedBuilder(
212 self::$bookmarkService, 187 self::$bookmarkService,
213 self::$formatter, 188 self::$formatter,
214 FeedBuilder::$FEED_ATOM, 189 static::$serverInfo,
215 self::$serverInfo,
216 null,
217 false 190 false
218 ); 191 );
219 $feedBuilder->setLocale(self::$LOCALE); 192 $feedBuilder->setLocale(self::$LOCALE);
220 $feedBuilder->setUsePermalinks(true); 193 $feedBuilder->setUsePermalinks(true);
221 $data = $feedBuilder->buildData(); 194 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null);
222 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); 195 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links']));
223 $this->assertTrue($data['usepermalinks']); 196 $this->assertTrue($data['usepermalinks']);
224 // First link is a permalink 197 // First link is a permalink
@@ -247,14 +220,12 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
247 $feedBuilder = new FeedBuilder( 220 $feedBuilder = new FeedBuilder(
248 self::$bookmarkService, 221 self::$bookmarkService,
249 self::$formatter, 222 self::$formatter,
250 FeedBuilder::$FEED_ATOM, 223 static::$serverInfo,
251 self::$serverInfo,
252 null,
253 false 224 false
254 ); 225 );
255 $feedBuilder->setLocale(self::$LOCALE); 226 $feedBuilder->setLocale(self::$LOCALE);
256 $feedBuilder->setHideDates(true); 227 $feedBuilder->setHideDates(true);
257 $data = $feedBuilder->buildData(); 228 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null);
258 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); 229 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links']));
259 $this->assertFalse($data['show_dates']); 230 $this->assertFalse($data['show_dates']);
260 231
@@ -262,14 +233,12 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
262 $feedBuilder = new FeedBuilder( 233 $feedBuilder = new FeedBuilder(
263 self::$bookmarkService, 234 self::$bookmarkService,
264 self::$formatter, 235 self::$formatter,
265 FeedBuilder::$FEED_ATOM, 236 static::$serverInfo,
266 self::$serverInfo,
267 null,
268 true 237 true
269 ); 238 );
270 $feedBuilder->setLocale(self::$LOCALE); 239 $feedBuilder->setLocale(self::$LOCALE);
271 $feedBuilder->setHideDates(true); 240 $feedBuilder->setHideDates(true);
272 $data = $feedBuilder->buildData(); 241 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null);
273 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); 242 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links']));
274 $this->assertTrue($data['show_dates']); 243 $this->assertTrue($data['show_dates']);
275 } 244 }
@@ -289,13 +258,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase
289 $feedBuilder = new FeedBuilder( 258 $feedBuilder = new FeedBuilder(
290 self::$bookmarkService, 259 self::$bookmarkService,
291 self::$formatter, 260 self::$formatter,
292 FeedBuilder::$FEED_ATOM,
293 $serverInfo, 261 $serverInfo,
294 null,
295 false 262 false
296 ); 263 );
297 $feedBuilder->setLocale(self::$LOCALE); 264 $feedBuilder->setLocale(self::$LOCALE);
298 $data = $feedBuilder->buildData(); 265 $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null);
299 266
300 $this->assertEquals( 267 $this->assertEquals(
301 'http://host.tld:8080/~user/shaarli/index.php?do=feed', 268 'http://host.tld:8080/~user/shaarli/index.php?do=feed',