mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-11 18:32:41 +00:00
Feed tests: deduplication
This commit is contained in:
parent
c800852f3a
commit
ff59f00356
6 changed files with 183 additions and 13 deletions
|
@ -20,6 +20,7 @@ class TestFeed extends \PHPUnit\Framework\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDeduplicateFeedItems() {
|
function testDeduplicateFeedItems() {
|
||||||
|
// duplicates with dates lead to the newest match being kept
|
||||||
$t = strtotime("2002-05-19T15:21:36Z");
|
$t = strtotime("2002-05-19T15:21:36Z");
|
||||||
$f = new Feed(null, $this->base."Deduplication/Permalink-Dates");
|
$f = new Feed(null, $this->base."Deduplication/Permalink-Dates");
|
||||||
$this->assertCount(2, $f->newItems);
|
$this->assertCount(2, $f->newItems);
|
||||||
|
@ -30,6 +31,19 @@ class TestFeed extends \PHPUnit\Framework\TestCase {
|
||||||
$f = new Feed(null, $this->base."Deduplication/IdenticalHashes");
|
$f = new Feed(null, $this->base."Deduplication/IdenticalHashes");
|
||||||
$this->assertCount(2, $f->newItems);
|
$this->assertCount(2, $f->newItems);
|
||||||
$this->assertTime($t, $f->newItems[0]->updatedDate);
|
$this->assertTime($t, $f->newItems[0]->updatedDate);
|
||||||
|
$f = new Feed(null, $this->base."Deduplication/Hashes-Dates1"); // content differs
|
||||||
|
$this->assertCount(2, $f->newItems);
|
||||||
|
$this->assertTime($t, $f->newItems[0]->updatedDate);
|
||||||
|
$f = new Feed(null, $this->base."Deduplication/Hashes-Dates2"); // title differs
|
||||||
|
$this->assertCount(2, $f->newItems);
|
||||||
|
$this->assertTime($t, $f->newItems[0]->updatedDate);
|
||||||
|
$f = new Feed(null, $this->base."Deduplication/Hashes-Dates3"); // URL differs
|
||||||
|
$this->assertCount(2, $f->newItems);
|
||||||
|
$this->assertTime($t, $f->newItems[0]->updatedDate);
|
||||||
|
// duplicates without dates lead to the topmost entry being kept
|
||||||
|
$f = new Feed(null, $this->base."Deduplication/Hashes");
|
||||||
|
$this->assertCount(2, $f->newItems);
|
||||||
|
$this->assertSame("http://example.com/1", $f->newItems[0]->url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testHandleCacheHeadersOn304() {
|
function testHandleCacheHeadersOn304() {
|
||||||
|
|
41
tests/docroot/Feed/Deduplication/Hashes-Dates1.php
Normal file
41
tests/docroot/Feed/Deduplication/Hashes-Dates1.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php return [
|
||||||
|
'mime' => "application/rss+xml",
|
||||||
|
'content' => <<<MESSAGE_BODY
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>Test feed</title>
|
||||||
|
<link>http://example.com/</link>
|
||||||
|
<description>A basic feed for testing</description>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 1995 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>2002-02-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 2</description>
|
||||||
|
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate> <!-- This is the correct item and date -->
|
||||||
|
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 3</description>
|
||||||
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The Second</title>
|
||||||
|
<link>http://example.com/2</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
MESSAGE_BODY
|
||||||
|
];
|
41
tests/docroot/Feed/Deduplication/Hashes-Dates2.php
Normal file
41
tests/docroot/Feed/Deduplication/Hashes-Dates2.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php return [
|
||||||
|
'mime' => "application/rss+xml",
|
||||||
|
'content' => <<<MESSAGE_BODY
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>Test feed</title>
|
||||||
|
<link>http://example.com/</link>
|
||||||
|
<description>A basic feed for testing</description>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 1995 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>2002-02-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First!</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate> <!-- This is the correct item and date -->
|
||||||
|
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First?</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The Second</title>
|
||||||
|
<link>http://example.com/2</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
MESSAGE_BODY
|
||||||
|
];
|
41
tests/docroot/Feed/Deduplication/Hashes-Dates3.php
Normal file
41
tests/docroot/Feed/Deduplication/Hashes-Dates3.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php return [
|
||||||
|
'mime' => "application/rss+xml",
|
||||||
|
'content' => <<<MESSAGE_BODY
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>Test feed</title>
|
||||||
|
<link>http://example.com/</link>
|
||||||
|
<description>A basic feed for testing</description>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1?</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 1995 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>2002-02-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate> <!-- This is the correct item and date -->
|
||||||
|
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1?ook=</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The Second</title>
|
||||||
|
<link>http://example.com/2</link>
|
||||||
|
<description>Sample article 4</description>
|
||||||
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
MESSAGE_BODY
|
||||||
|
];
|
33
tests/docroot/Feed/Deduplication/Hashes.php
Normal file
33
tests/docroot/Feed/Deduplication/Hashes.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php return [
|
||||||
|
'mime' => "application/rss+xml",
|
||||||
|
'content' => <<<MESSAGE_BODY
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>Test feed</title>
|
||||||
|
<link>http://example.com/</link>
|
||||||
|
<description>A basic feed for testing</description>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1</link> <!-- This is the correct item -->
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1?</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The First</title>
|
||||||
|
<link>http://example.com/1?ook=</link>
|
||||||
|
<description>Sample article 1</description>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>Article The Second</title>
|
||||||
|
<link>http://example.com/2</link>
|
||||||
|
<description>Sample article 4</description>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
MESSAGE_BODY
|
||||||
|
];
|
|
@ -9,27 +9,27 @@
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<guid>1</guid>
|
<guid>1</guid>
|
||||||
<description>Sample article 2</description>
|
<description>Sample article 1</description>
|
||||||
|
<pubDate>Sun, 18 May 1995 15:21:36 GMT</pubDate>
|
||||||
|
<atom:updated>2002-02-19T15:21:36Z</atom:updated>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<guid>1</guid>
|
||||||
|
<description>Sample article 1</description>
|
||||||
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate> <!-- This is the correct item and date -->
|
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate> <!-- This is the correct item and date -->
|
||||||
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<guid>1</guid>
|
<guid>1</guid>
|
||||||
<description>Sample article 2</description>
|
<description>Sample article 1</description>
|
||||||
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<guid>1</guid>
|
|
||||||
<description>Sample article 2</description>
|
|
||||||
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
|
|
||||||
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<guid>2</guid>
|
<guid>2</guid>
|
||||||
<description>Sample article 2</description>
|
<description>Sample article 1</description>
|
||||||
<pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
|
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
|
||||||
<atom:updated>2002-04-19T15:21:36Z</atom:updated>
|
<atom:updated>1999-05-19T15:21:36Z</atom:updated>
|
||||||
</item>
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
|
|
Loading…
Reference in a new issue