summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2019-03-25 22:53:38 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2019-03-26 09:31:03 +0100
commitb37e237c7a8618a043bbf56b048f5604a0f854e8 (patch)
tree940eb2003c4f8733c63e42c62136ef5a9704ebe4 /tests
parent08e44b8460e73f6c47de80c54bd90fb09cfe43b1 (diff)
Fix xkcd commics
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php58
1 files changed, 54 insertions, 4 deletions
diff --git a/tests/Unit/Fetcher/FeedFetcherTest.php b/tests/Unit/Fetcher/FeedFetcherTest.php
index 5f3420810..72badf093 100644
--- a/tests/Unit/Fetcher/FeedFetcherTest.php
+++ b/tests/Unit/Fetcher/FeedFetcherTest.php
@@ -18,15 +18,11 @@ use FeedIo\Feed\Item\Author;
use FeedIo\Feed\Item\MediaInterface;
use FeedIo\Feed\ItemInterface;
use FeedIo\FeedInterface;
-use Favicon\Favicon;
use OC\L10N\L10N;
-use OCA\AdminAudit\Actions\Auth;
use \OCA\News\Db\Feed;
use \OCA\News\Db\Item;
use OCA\News\Fetcher\FeedFetcher;
use OCA\News\Utility\PsrLogger;
-use OCA\News\Utility\Time;
-use OCP\IL10N;
use PHPUnit\Framework\TestCase;
@@ -244,6 +240,60 @@ class FeedFetcherTest extends TestCase
}
/**
+ * Return body options
+ * @return array
+ */
+ public function feedBodyProvider()
+ {
+ return [
+ [
+ '<![CDATA[let the bodies hit the floor <a href="test">test</a>]]>',
+ 'let the bodies hit the floor <a href="test">test</a>'
+ ],
+ [
+ 'let the bodies hit the floor <a href="test">test</a>',
+ 'let the bodies hit the floor <a href="test">test</a>'
+ ],
+ [
+ 'let the bodies hit the floor "test" test',
+ 'let the bodies hit the floor "test" test'
+ ],
+ [
+ '<img src="https://imgs.xkcd.com/google_trends_maps.png" title="It\'s early 2020. The entire country is gripped with Marco Rubio" />',
+ '<img src="https://imgs.xkcd.com/google_trends_maps.png" title="It\'s early 2020. The entire country is gripped with Marco Rubio" />'
+ ],
+ ];
+ }
+
+ /**
+ * Test if body is set correctly.
+ *
+ * @dataProvider feedBodyProvider
+ *
+ * @param string $body The body before parsing.
+ * @param string $parsed_body The body after parsing.
+ */
+ public function testFetchWithFeedContent($body, $parsed_body)
+ {
+ $bodyBackup = $this->body;
+ $parsedBackup = $this->parsed_body;
+
+ $this->body = $body;
+ $this->parsed_body = $parsed_body;
+
+ $this->setUpReader($this->url, null, true);
+ $item = $this->createItem();
+ $feed = $this->createFeed();
+ $this->mockIterator($this->feed_mock, [$this->item_mock]);
+ $result = $this->fetcher->fetch($this->url, false, '0', null, null);
+
+ $this->assertEquals([$feed, [$item]], $result);
+
+ $this->body = $bodyBackup;
+ $this->parsed_body = $parsedBackup;
+ }
+
+ /**
* Test if the fetch function fetches a feed.
*/
public function testFetch()