summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/picofeed/tests')
-rw-r--r--vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php131
-rw-r--r--vendor/fguillot/picofeed/tests/Filter/FilterTest.php161
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php421
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/ItemTest.php12
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/ParserTest.php49
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/Rss10ParserTest.php329
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php327
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php2
-rw-r--r--vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php18
-rw-r--r--vendor/fguillot/picofeed/tests/Reader/FaviconTest.php2
-rw-r--r--vendor/fguillot/picofeed/tests/Reader/ReaderTest.php53
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/allgemeine-zeitung.xml122
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom.xml570
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_element_preference.xml38
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_empty_feed.xml9
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_empty_item.xml4
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_extra.xml19
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_fallback_on_invalid_feed_values.xml15
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_fallback_on_invalid_item_values.xml28
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_no_default_namespace.xml92
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/atom_prefixed.xml93
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/bbc_urdu.xml2087
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/biertaucher.xml7198
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/debug_show.xml1073
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/duesseldorf_lokalzeit.rdf111
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/fanboys.fm_episodes.all.mp3.rss10426
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/geekstammtisch.de_episodes.mp3.rss9428
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/googleblog.xml477
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/grotte_barbu.xml396
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/hamakor.xml527
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/radio-france.xml946
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss20.xml300
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10.xml69
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_element_preference.xml51
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_empty_channel.xml13
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_empty_feed.xml10
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_empty_item.xml5
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_extra.xml25
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_fallback_on_invalid_feed_values.xml18
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_fallback_on_invalid_item_values.xml39
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_no_default_namespace.xml69
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_10_prefixed.xml42
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20.xml81
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_dc.xml18
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_element_preference.xml69
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_empty_channel.xml12
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_empty_feed.xml9
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_empty_item.xml6
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_extra.xml30
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_fallback_on_invalid_feed_values.xml17
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/rss_20_fallback_on_invalid_item_values.xml34
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/womensweardaily.xml63
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/youtube.xml979
-rw-r--r--vendor/fguillot/picofeed/tests/fixtures/zoot_egkty.xml177
54 files changed, 2527 insertions, 34773 deletions
diff --git a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php
index 5dcfda141..6c68ef433 100644
--- a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php
+++ b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php
@@ -4,6 +4,7 @@ namespace PicoFeed\Filter;
use PHPUnit_Framework_TestCase;
use PicoFeed\Client\Url;
+use PicoFeed\Config\Config;
class AttributeFilterTest extends PHPUnit_Framework_TestCase
@@ -190,4 +191,134 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase
$this->assertEquals('title=""a""', $filter->toHtml(array('title' => '"a"')));
$this->assertEquals('title="ç" alt="b"', $filter->toHtml(array('title' => 'ç', 'alt' => 'b')));
}
+
+ public function testNoImageProxySet()
+ {
+ $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo');
+
+ $this->assertEquals(
+ '<p>Image <img src="http://foo/image.png" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyWithHTTPLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyWithHTTPSLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+
+ $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToUnknownProtocol()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('tripleX');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToHTTPwithHTTPLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('http');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToHTTPwithHTTPSLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('http');
+
+ $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToHTTPSwithHTTPLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('https');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToHTTPSwithHTTPSLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('https');
+
+ $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testsetFilterImageProxyCallback()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyCallback(function ($image_url) {
+ $key = hash_hmac('sha1', $image_url, 'secret');
+ return 'https://mypublicproxy/'.$key.'/'.rawurlencode($image_url);
+ });
+
+ $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="https://mypublicproxy/4924964043f3119b3cf2b07b1922d491bcc20092/'.rawurlencode('http://foo/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
}
diff --git a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
index f5f98a96b..29cff4668 100644
--- a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
+++ b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
@@ -37,9 +37,6 @@ class FilterTest extends PHPUnit_Framework_TestCase
$data = file_get_contents('tests/fixtures/sametmax.xml');
$this->assertEquals('<rss', substr(Filter::stripXmlTag($data), 0, 4));
- $data = file_get_contents('tests/fixtures/grotte_barbu.xml');
- $this->assertEquals('<rss', substr(Filter::stripXmlTag($data), 0, 4));
-
$data = file_get_contents('tests/fixtures/ibash.ru.xml');
$this->assertEquals('<rss', substr(Filter::stripXmlTag($data), 0, 4));
@@ -58,7 +55,7 @@ class FilterTest extends PHPUnit_Framework_TestCase
$data = file_get_contents('tests/fixtures/lagrange.xml');
$this->assertEquals('<feed', substr(Filter::stripXmlTag($data), 0, 5));
- $data = file_get_contents('tests/fixtures/atom.xml');
+ $data = file_get_contents('tests/fixtures/googleblog.xml');
$this->assertEquals('<feed', substr(trim(Filter::stripXmlTag($data)), 0, 5));
$data = file_get_contents('tests/fixtures/atomsample.xml');
@@ -91,133 +88,35 @@ class FilterTest extends PHPUnit_Framework_TestCase
$this->assertEquals('<p>Testboo</p>', $f->execute());
}
- public function testNoImageProxySet()
- {
- $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo');
-
- $this->assertEquals(
- '<p>Image <img src="http://foo/image.png" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyWithHTTPLink()
- {
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
-
- $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://localhost/image.png').'" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyWithHTTPSLink()
- {
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
-
- $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyLimitedToUnknownProtocol()
+ public function testNormalizeData()
{
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
- $config->setFilterImageProxyProtocol('tripleX');
-
- $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyLimitedToHTTPwithHTTPLink()
- {
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
- $config->setFilterImageProxyProtocol('http');
-
- $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://localhost/image.png').'" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyLimitedToHTTPwithHTTPSLink()
- {
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
- $config->setFilterImageProxyProtocol('http');
-
- $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyLimitedToHTTPSwithHTTPLink()
- {
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
- $config->setFilterImageProxyProtocol('https');
-
- $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testImageProxyLimitedToHTTPSwithHTTPSLink()
- {
- $config = new Config;
- $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
- $config->setFilterImageProxyProtocol('https');
-
- $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>',
- $f->execute()
- );
- }
-
- public function testsetFilterImageProxyCallback()
- {
- $config = new Config;
- $config->setFilterImageProxyCallback(function ($image_url) {
- $key = hash_hmac('sha1', $image_url, 'secret');
- return 'https://mypublicproxy/'.$key.'/'.rawurlencode($image_url);
- });
-
- $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo');
- $f->setConfig($config);
-
- $this->assertEquals(
- '<p>Image <img src="https://mypublicproxy/4924964043f3119b3cf2b07b1922d491bcc20092/'.rawurlencode('http://foo/image.png').'" alt="My Image"/></p>',
- $f->execute()
- );
+ // invalid data link escape control character
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random\x10 text</xml>"));
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random&#x10; text</xml>"));
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random&#16; text</xml>"));
+
+ // invalid unit seperator control character (lower and upper case)
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random\x1f text</xml>"));
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random\x1F text</xml>"));
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random&#x1f; text</xml>"));
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random&#x1F; text</xml>"));
+ $this->assertEquals('<xml>random text</xml>', Filter::normalizeData("<xml>random&#31; text</xml>"));
+
+ /*
+ * Do not test invalid multibyte characters. The output depends on php
+ * version and character.
+ *
+ * php 5.3: always null
+ * php >5.3: sometime null, sometimes the stripped string
+ */
+
+ // invalid backspace control character + valid multibyte character
+ $this->assertEquals('<xml>“random“ text</xml>', Filter::normalizeData("<xml>\xe2\x80\x9crandom\xe2\x80\x9c\x08 text</xml>"));
+ $this->assertEquals('<xml>&#x201C;random&#x201C; text</xml>', Filter::normalizeData("<xml>&#x201C;random&#x201C;&#x08; text</xml>"));
+ $this->assertEquals('<xml>&#8220;random&#8220; text</xml>', Filter::normalizeData("<xml>&#8220;random&#8220;&#08; text</xml>"));
+
+ // do not convert valid entities to utf-8 character
+ $this->assertEquals('<xml attribute="&#34;value&#34;">random text</xml>', Filter::normalizeData('<xml attribute="&#34;value&#34;">random text</xml>'));
+ $this->assertEquals('<xml attribute="&#x22;value&#x22;">random text</xml>', Filter::normalizeData('<xml attribute="&#x22;value&#x22;">random text</xml>'));
}
} \ No newline at end of file
diff --git a/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php b/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php
index 9c2526c04..5cbd0eeb8 100644
--- a/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php
+++ b/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php
@@ -14,249 +14,450 @@ class AtomParserTest extends PHPUnit_Framework_TestCase
$parser->execute();
}
- public function testFeedTitle()
+ public function testGetItemsTree()
{
$parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));
$feed = $parser->execute();
- $this->assertEquals('The Official Google Blog', $feed->getTitle());
+ $this->assertCount(4, $feed->items);
- $parser = new Atom(file_get_contents('tests/fixtures/atomsample.xml'));
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_no_default_namespace.xml'));
$feed = $parser->execute();
- $this->assertEquals('Example Feed', $feed->getTitle());
+ $this->assertCount(4, $feed->items);
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_prefixed.xml'));
+ $feed = $parser->execute();
+ $this->assertCount(4, $feed->items);
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_empty_feed.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals(array(), $feed->items);
+ }
+
+ public function testFindFeedTitle()
+ {
+ $parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals('литература на русском языке, либо написанная русскими авторами', $feed->getTitle());
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_no_default_namespace.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals('литература на русском языке, либо написанная русскими авторами', $feed->getTitle());
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_prefixed.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals('литература на русском языке, либо написанная русскими авторами', $feed->getTitle());
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_fallback_on_invalid_feed_values.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals('https://en.wikipedia.org/wiki/Category:Russian-language_literature', $feed->getTitle());
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_empty_feed.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals('', $feed->getTitle());
}
- public function testFeedDescription()
+ public function testFindFeedDescription()
{
$parser = new Atom(file_get_contents('tests/fixtures/atom.xml'));
$feed = $parser->execute();
- $this->assertEquals('Insights from Googlers into our products, technology, and the Google culture.', $feed->getDescription());
+ $this->assertEquals("Зародилась во второй половине X века, однако до XIX века,\nкогда начался её «золотой век», была практически неизвестна\nв мире.", $feed->getDescription());
- $parser = new Atom(file_get_contents('tests/fixtures/atomsample.xml'));
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_no_default_namespace.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals("Зародилась во второй половине X века, однако до XIX века,\nкогда начался её «золотой век», была практически неизвестна\nв мире.", $feed->getDescription());
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_prefixed.xml'));
+ $feed = $parser->execute();
+ $this->assertEquals("Зародилась во второй половине X века, однако до XIX века,\nкогда начался её «золотой век», была практически неизвестна\nв мире.", $feed->getDescription());
+
+ $parser = new Atom(file_get_contents('tests/fixtures/atom_empty_feed.xml'));
$feed = $parser->execute();
$this->assertEquals('', $feed->getDescription());