1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Don't fetch from example.com during tests

This commit is contained in:
J. King 2021-01-08 16:46:21 -05:00
parent 549c7bdc72
commit 9e29235d87
36 changed files with 78 additions and 71 deletions

View file

@ -22,12 +22,12 @@ class TestOPML extends \JKingWeb\Arsse\Test\AbstractTest {
['id' => 1, 'parent' => null, 'children' => 1, 'feeds' => 1, 'name' => "Science"],
];
protected $subscriptions = [
['id' => 3, 'folder' => 1, 'top_folder' => 1, 'unread' => 2, 'updated' => "2016-05-23 06:40:02", 'err_msg' => 'argh', 'title' => 'Ars Technica', 'url' => "http://example.com/3", 'favicon' => 'http://example.com/3.png'],
['id' => 4, 'folder' => 6, 'top_folder' => 3, 'unread' => 6, 'updated' => "2017-10-09 15:58:34", 'err_msg' => '', 'title' => 'CBC News', 'url' => "http://example.com/4", 'favicon' => 'http://example.com/4.png'],
['id' => 6, 'folder' => null, 'top_folder' => null, 'unread' => 0, 'updated' => "2010-02-12 20:08:47", 'err_msg' => '', 'title' => 'Eurogamer', 'url' => "http://example.com/6", 'favicon' => 'http://example.com/6.png'],
['id' => 1, 'folder' => 2, 'top_folder' => 1, 'unread' => 5, 'updated' => "2017-09-15 22:54:16", 'err_msg' => '', 'title' => 'NASA JPL', 'url' => "http://example.com/1", 'favicon' => null],
['id' => 5, 'folder' => 6, 'top_folder' => 3, 'unread' => 12, 'updated' => "2017-07-07 17:07:17", 'err_msg' => '', 'title' => 'Ottawa Citizen', 'url' => "http://example.com/5", 'favicon' => ''],
['id' => 2, 'folder' => 5, 'top_folder' => 3, 'unread' => 10, 'updated' => "2011-11-11 11:11:11", 'err_msg' => 'oops', 'title' => 'Toronto Star', 'url' => "http://example.com/2", 'favicon' => 'http://example.com/2.png'],
['id' => 3, 'folder' => 1, 'top_folder' => 1, 'unread' => 2, 'updated' => "2016-05-23 06:40:02", 'err_msg' => 'argh', 'title' => 'Ars Technica', 'url' => "http://localhost:8000/3", 'favicon' => 'http://localhost:8000/3.png'],
['id' => 4, 'folder' => 6, 'top_folder' => 3, 'unread' => 6, 'updated' => "2017-10-09 15:58:34", 'err_msg' => '', 'title' => 'CBC News', 'url' => "http://localhost:8000/4", 'favicon' => 'http://localhost:8000/4.png'],
['id' => 6, 'folder' => null, 'top_folder' => null, 'unread' => 0, 'updated' => "2010-02-12 20:08:47", 'err_msg' => '', 'title' => 'Eurogamer', 'url' => "http://localhost:8000/6", 'favicon' => 'http://localhost:8000/6.png'],
['id' => 1, 'folder' => 2, 'top_folder' => 1, 'unread' => 5, 'updated' => "2017-09-15 22:54:16", 'err_msg' => '', 'title' => 'NASA JPL', 'url' => "http://localhost:8000/1", 'favicon' => null],
['id' => 5, 'folder' => 6, 'top_folder' => 3, 'unread' => 12, 'updated' => "2017-07-07 17:07:17", 'err_msg' => '', 'title' => 'Ottawa Citizen', 'url' => "http://localhost:8000/5", 'favicon' => ''],
['id' => 2, 'folder' => 5, 'top_folder' => 3, 'unread' => 10, 'updated' => "2011-11-11 11:11:11", 'err_msg' => 'oops', 'title' => 'Toronto Star', 'url' => "http://localhost:8000/2", 'favicon' => 'http://localhost:8000/2.png'],
];
protected $tags = [
['id' => 1, 'name' => "Canada", 'subscription' => 2],
@ -47,20 +47,20 @@ class TestOPML extends \JKingWeb\Arsse\Test\AbstractTest {
<outline text="Photography"/>
<outline text="Politics">
<outline text="Local">
<outline type="rss" text="Toronto Star" xmlUrl="http://example.com/2" category="Canada"/>
<outline type="rss" text="Toronto Star" xmlUrl="http://localhost:8000/2" category="Canada"/>
</outline>
<outline text="National">
<outline type="rss" text="CBC News" xmlUrl="http://example.com/4" category="Canada,Politics"/>
<outline type="rss" text="Ottawa Citizen" xmlUrl="http://example.com/5" category="Canada,Politics"/>
<outline type="rss" text="CBC News" xmlUrl="http://localhost:8000/4" category="Canada,Politics"/>
<outline type="rss" text="Ottawa Citizen" xmlUrl="http://localhost:8000/5" category="Canada,Politics"/>
</outline>
</outline>
<outline text="Science">
<outline text="Rocketry">
<outline type="rss" text="NASA JPL" xmlUrl="http://example.com/1" category="Science etc"/>
<outline type="rss" text="NASA JPL" xmlUrl="http://localhost:8000/1" category="Science etc"/>
</outline>
<outline type="rss" text="Ars Technica" xmlUrl="http://example.com/3" category="Science etc"/>
<outline type="rss" text="Ars Technica" xmlUrl="http://localhost:8000/3" category="Science etc"/>
</outline>
<outline type="rss" text="Eurogamer" xmlUrl="http://example.com/6"/>
<outline type="rss" text="Eurogamer" xmlUrl="http://localhost:8000/6"/>
</body>
</opml>
OPML_EXPORT_SERIALIZATION;
@ -69,12 +69,12 @@ OPML_EXPORT_SERIALIZATION;
<opml version="2.0">
<head/>
<body>
<outline type="rss" text="Ars Technica" xmlUrl="http://example.com/3" category="Science etc"/>
<outline type="rss" text="CBC News" xmlUrl="http://example.com/4" category="Canada,Politics"/>
<outline type="rss" text="Eurogamer" xmlUrl="http://example.com/6"/>
<outline type="rss" text="NASA JPL" xmlUrl="http://example.com/1" category="Science etc"/>
<outline type="rss" text="Ottawa Citizen" xmlUrl="http://example.com/5" category="Canada,Politics"/>
<outline type="rss" text="Toronto Star" xmlUrl="http://example.com/2" category="Canada"/>
<outline type="rss" text="Ars Technica" xmlUrl="http://localhost:8000/3" category="Science etc"/>
<outline type="rss" text="CBC News" xmlUrl="http://localhost:8000/4" category="Canada,Politics"/>
<outline type="rss" text="Eurogamer" xmlUrl="http://localhost:8000/6"/>
<outline type="rss" text="NASA JPL" xmlUrl="http://localhost:8000/1" category="Science etc"/>
<outline type="rss" text="Ottawa Citizen" xmlUrl="http://localhost:8000/5" category="Canada,Politics"/>
<outline type="rss" text="Toronto Star" xmlUrl="http://localhost:8000/2" category="Canada"/>
</body>
</opml>
OPML_EXPORT_SERIALIZATION;
@ -129,10 +129,10 @@ OPML_EXPORT_SERIALIZATION;
["Empty.2.opml", false, [[], []]],
["Empty.3.opml", false, [[], []]],
["FeedsOnly.opml", false, [[
['url' => "http://example.com/1", 'title' => "Feed 1", 'folder' => 0, 'tags' => []],
['url' => "http://example.com/2", 'title' => "", 'folder' => 0, 'tags' => []],
['url' => "http://example.com/3", 'title' => "", 'folder' => 0, 'tags' => []],
['url' => "http://example.com/4", 'title' => "", 'folder' => 0, 'tags' => []],
['url' => "http://localhost:8000/1", 'title' => "Feed 1", 'folder' => 0, 'tags' => []],
['url' => "http://localhost:8000/2", 'title' => "", 'folder' => 0, 'tags' => []],
['url' => "http://localhost:8000/3", 'title' => "", 'folder' => 0, 'tags' => []],
['url' => "http://localhost:8000/4", 'title' => "", 'folder' => 0, 'tags' => []],
['url' => "", 'title' => "", 'folder' => 0, 'tags' => ["whee"]],
['url' => "", 'title' => "", 'folder' => 0, 'tags' => ["whee", "whoo"]],
], []]],

View file

@ -6,7 +6,7 @@
<rss version="2.0">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
</channel>
</rss>

View file

@ -6,7 +6,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -6,7 +6,7 @@
<rss version="2.0">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -6,7 +6,7 @@
<rss version="2.0">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
</channel>
</rss>

View file

@ -6,7 +6,7 @@
<rss version="2.0">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -6,7 +6,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>

View file

@ -4,29 +4,29 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>A basic feed for testing</description>
<item>
<guid>http://example.com/1</guid>
<guid>http://localhost:8000/1</guid>
<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>http://example.com/1</guid>
<guid>http://localhost:8000/1</guid>
<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>
<guid>http://example.com/1</guid>
<guid>http://localhost:8000/1</guid>
<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>
<guid>http://example.com/2</guid>
<guid>http://localhost:8000/2</guid>
<description>Sample article 4</description>
<pubDate>Sun, 18 May 2000 15:21:36 GMT</pubDate>
<atom:updated>1999-05-19T15:21:36Z</atom:updated>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>Example newsfeed title</description>
</channel>
</rss>

View file

@ -9,7 +9,7 @@ return [
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>Example newsfeed title</description>
$item
</channel>

View file

@ -4,7 +4,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example feed title</title>
<id>urn:uuid:0fd8f6d8-43df-11e7-8511-9b59a0324eb8</id>
<link rel="alternate" type="text/html" href="http://example.com/"/>
<link rel="alternate" type="text/html" href="http://localhost:8000/"/>
<entry>
<id>urn:uuid:df329114-43df-11e7-9f23-a938604d62f8</id>

View file

@ -4,7 +4,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example feed title</title>
<id>urn:uuid:0fd8f6d8-43df-11e7-8511-9b59a0324eb8</id>
<link rel="alternate" type="text/html" href="http://example.com/"/>
<link rel="alternate" type="text/html" href="http://localhost:8000/"/>
<entry>
<id>urn:uuid:df329114-43df-11e7-9f23-a938604d62f8</id>

View file

@ -4,7 +4,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example feed title</title>
<id>urn:uuid:0fd8f6d8-43df-11e7-8511-9b59a0324eb8</id>
<link rel="alternate" type="text/html" href="http://example.com/"/>
<link rel="alternate" type="text/html" href="http://localhost:8000/"/>
<entry>
<id>urn:uuid:df329114-43df-11e7-9f23-a938604d62f8</id>

View file

@ -4,7 +4,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example feed title</title>
<id>urn:uuid:0fd8f6d8-43df-11e7-8511-9b59a0324eb8</id>
<link rel="alternate" type="text/html" href="http://example.com/"/>
<link rel="alternate" type="text/html" href="http://localhost:8000/"/>
<entry>
<id>urn:uuid:df329114-43df-11e7-9f23-a938604d62f8</id>

View file

@ -4,7 +4,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example feed title</title>
<id>urn:uuid:0fd8f6d8-43df-11e7-8511-9b59a0324eb8</id>
<link rel="alternate" type="text/html" href="http://example.com/"/>
<link rel="alternate" type="text/html" href="http://localhost:8000/"/>
<entry>
<id>urn:uuid:3d5f5154-43e1-11e7-ba11-1dcae392a974</id>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Example title</title>
<link>http://example.com</link>
<link>http://localhost:8000/</link>
<description>Example description</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Example title</title>
<link>http://example.com</link>
<link>http://localhost:8000/</link>
<description>Example description</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Example title</title>
<link>http://example.com</link>
<link>http://localhost:8000/</link>
<description>Example description</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Example title</title>
<link>http://example.com</link>
<link>http://localhost:8000/</link>
<description>Example description</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Example title</title>
<link>http://example.com</link>
<link>http://localhost:8000/</link>
<description>Example description</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Example title</title>
<link>http://example.com</link>
<link>http://localhost:8000/</link>
<description>Example description</description>
<item>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>Example newsfeed title</description>
<item>

View file

@ -16,30 +16,30 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>Example newsfeed title</description>
<item>
<dc:identifier>urn:uuid:43fb1908-42ec-11e7-b61b-2b118faca2f2</dc:identifier>
<guid>http://example.com/1</guid>
<guid>http://localhost:8000/1</guid>
<atom:id>urn:uuid:4c8dbc84-42eb-11e7-9f61-6f83db96854f</atom:id> <!-- Correct ID -->
</item>
<item>
<dc:identifier>urn:uuid:43fb1908-42ec-11e7-b61b-2b118faca2f2</dc:identifier>
<guid>http://example.com/1</guid> <!-- Correct ID -->
<guid>http://localhost:8000/1</guid> <!-- Correct ID -->
</item>
<item>
<dc:identifier>urn:uuid:43fb1908-42ec-11e7-b61b-2b118faca2f2</dc:identifier> <!-- Correct ID -->
</item>
<item>
<link>http://example.com/2</link>
<link>http://localhost:8000/2</link>
</item>
<item>
<title>Example title</title>
</item>
<item>
<description>Example content</description>
<enclosure url="http://example.com/text" type="text/plain"/>
<enclosure url="http://localhost:8000/text" type="text/plain"/>
</item>
</channel>
</rss>

View file

@ -7,30 +7,30 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>&xxe;</description>
<item>
<dc:identifier>urn:uuid:43fb1908-42ec-11e7-b61b-2b118faca2f2</dc:identifier>
<guid>http://example.com/1</guid>
<guid>http://localhost:8000/1</guid>
<atom:id>urn:uuid:4c8dbc84-42eb-11e7-9f61-6f83db96854f</atom:id> <!-- Correct ID -->
</item>
<item>
<dc:identifier>urn:uuid:43fb1908-42ec-11e7-b61b-2b118faca2f2</dc:identifier>
<guid>http://example.com/1</guid> <!-- Correct ID -->
<guid>http://localhost:8000/1</guid> <!-- Correct ID -->
</item>
<item>
<dc:identifier>urn:uuid:43fb1908-42ec-11e7-b61b-2b118faca2f2</dc:identifier> <!-- Correct ID -->
</item>
<item>
<link>http://example.com/2</link>
<link>http://localhost:8000/2</link>
</item>
<item>
<title>Example title</title>
</item>
<item>
<description>Example content</description>
<enclosure url="http://example.com/text" type="text/plain"/>
<enclosure url="http://localhost:8000/text" type="text/plain"/>
</item>
</channel>
</rss>

View file

@ -4,7 +4,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Test feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>Example newsfeed title</description>
<item>

View file

@ -1,2 +1,2 @@
<opml/>
<!-- Not body element -->
<!-- No body element -->

View file

@ -1,10 +1,10 @@
<opml>
<body>
<outline type="rss" xmlUrl="http://example.com/1" text="Feed 1"/>
<outline type="rss" xmlUrl="http://example.com/2" text=""/>
<outline type="rss" xmlUrl="http://example.com/3"/>
<outline type="rss" xmlUrl="http://example.com/4" title="Feed 4"> <!-- Only the "text" attribute is used -->
<outline type="rss" xmlUrl="http://example.com/!" title="Not a feed"/> <!-- Any descendants of a feed are skipped -->
<outline type="rss" xmlUrl="http://localhost:8000/1" text="Feed 1"/>
<outline type="rss" xmlUrl="http://localhost:8000/2" text=""/>
<outline type="rss" xmlUrl="http://localhost:8000/3"/>
<outline type="rss" xmlUrl="http://localhost:8000/4" title="Feed 4"> <!-- Only the "text" attribute is used -->
<outline type="rss" xmlUrl="http://localhost:8000/!" title="Not a feed"/> <!-- Any descendants of a feed are skipped -->
</outline>
<outline type="rss" xmlUrl="" category="whee"/>
<outline type="rss" category="whee,whoo,"/>

View file

@ -4,7 +4,7 @@
<rss version="2.0">
<channel>
<title>Some feed</title>
<link>http://example.com/</link>
<link>http://localhost:8000/</link>
<description>Just a generic feed</description>
<item>

4
tests/docroot/index.php Normal file
View file

@ -0,0 +1,4 @@
<?php return [
'code' => 204,
'content' => "",
];

View file

@ -41,6 +41,9 @@ $defaults = [ // default values for response
];
$url = explode("?", $_SERVER['REQUEST_URI'])[0];
if ($url === "/") {
$url = "/index";
}
$base = BASE."tests".\DIRECTORY_SEPARATOR."docroot";
$test = $base.str_replace("/", \DIRECTORY_SEPARATOR, $url).".php";
if (!file_exists($test)) {