diff options
Diffstat (limited to 'vendor/fguillot/picofeed/tests')
11 files changed, 157 insertions, 36 deletions
diff --git a/vendor/fguillot/picofeed/tests/Client/ClientTest.php b/vendor/fguillot/picofeed/tests/Client/ClientTest.php index 3f094d04c..8eaa34690 100644 --- a/vendor/fguillot/picofeed/tests/Client/ClientTest.php +++ b/vendor/fguillot/picofeed/tests/Client/ClientTest.php @@ -18,6 +18,20 @@ class ClientTest extends PHPUnit_Framework_TestCase $this->assertNotEmpty($client->getLastModified()); } +// // disabled due to https://github.com/sebastianbergmann/phpunit/issues/1452 +// /** +// * @runInSeparateProcess +// */ +// public function testPassthrough() +// { +// $client = Client::getInstance(); +// $client->setUrl('http://miniflux.net/favicon.ico'); +// $client->enablePassthroughMode(); +// $client->execute(); +// +// $this->expectOutputString('no_to_be_defined'); +// } + public function testCacheBothHaveToMatch() { $client = Client::getInstance(); diff --git a/vendor/fguillot/picofeed/tests/Client/CurlTest.php b/vendor/fguillot/picofeed/tests/Client/CurlTest.php index 4509dbc67..0ade6d207 100644 --- a/vendor/fguillot/picofeed/tests/Client/CurlTest.php +++ b/vendor/fguillot/picofeed/tests/Client/CurlTest.php @@ -18,18 +18,31 @@ class CurlTest extends PHPUnit_Framework_TestCase $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); } +// // disabled due to https://github.com/sebastianbergmann/phpunit/issues/1452 +// /** +// * @runInSeparateProcess +// */ +// public function testPassthrough() +// { +// $client = new Curl; +// $client->setUrl('http://miniflux.net/favicon.ico'); +// $client->enablePassthroughMode(); +// $client->doRequest(); +// +// $this->expectOutputString('no_to_be_defined'); +// } public function testRedirect() { $client = new Curl; - $client->setUrl('http://www.miniflux.net/index.html'); + $client->setUrl('http://rss.feedsportal.com/c/629/f/502199/s/42e50391/sc/44/l/0L0S0A1net0N0Ceditorial0C6437220Candroid0Egoogle0Enow0Es0Eouvre0Eaux0Eapplications0Etierces0C0T0Dxtor0FRSS0E16/story01.htm'); $result = $client->doRequest(); $this->assertTrue(is_array($result)); $this->assertEquals(200, $result['status']); $this->assertEquals('<!DOCTYPE', substr($result['body'], 0, 9)); - $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); - $this->assertEquals('http://miniflux.net/', $client->getUrl()); + $this->assertEquals('text/html', $result['headers']['Content-Type']); + $this->assertEquals('http://www.01net.com/editorial/643722/android-google-now-s-ouvre-aux-applications-tierces/', str_replace('#?xtor=RSS-16', '', $client->getUrl())); } /** diff --git a/vendor/fguillot/picofeed/tests/Client/StreamTest.php b/vendor/fguillot/picofeed/tests/Client/StreamTest.php index 91f52c898..83a5a20fb 100644 --- a/vendor/fguillot/picofeed/tests/Client/StreamTest.php +++ b/vendor/fguillot/picofeed/tests/Client/StreamTest.php @@ -27,17 +27,31 @@ class StreamTest extends PHPUnit_Framework_TestCase $this->assertEquals('</html>', substr(trim($result['body']), -7)); } +// // disabled due to https://github.com/sebastianbergmann/phpunit/issues/1452 +// /** +// * @runInSeparateProcess +// */ +// public function testPassthrough() +// { +// $client = new Stream; +// $client->setUrl('http://miniflux.net/favicon.ico'); +// $client->enablePassthroughMode(); +// $client->doRequest(); +// +// $this->expectOutputString('no_to_be_defined'); +// } + public function testRedirect() { $client = new Stream; - $client->setUrl('http://www.miniflux.net/index.html'); + $client->setUrl('http://rss.feedsportal.com/c/629/f/502199/s/42e50391/sc/44/l/0L0S0A1net0N0Ceditorial0C6437220Candroid0Egoogle0Enow0Es0Eouvre0Eaux0Eapplications0Etierces0C0T0Dxtor0FRSS0E16/story01.htm'); $result = $client->doRequest(); $this->assertTrue(is_array($result)); $this->assertEquals(200, $result['status']); $this->assertEquals('<!DOCTYPE', substr($result['body'], 0, 9)); - $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); - $this->assertEquals('http://miniflux.net/', $client->getUrl()); + $this->assertEquals('text/html', $result['headers']['Content-Type']); + $this->assertEquals('http://www.01net.com/editorial/643722/android-google-now-s-ouvre-aux-applications-tierces/#?xtor=RSS-16', $client->getUrl()); } /** diff --git a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php index 907aaa2d5..bf7dd224e 100644 --- a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php @@ -39,8 +39,8 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase $this->assertTrue($filter->filterIntegerAttribute('iframe', 'width', '450')); $this->assertFalse($filter->filterIntegerAttribute('iframe', 'width', 'test')); - $this->assertEquals(array('width' => '10', 'src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('width' => '10', 'src' => 'http://www.youtube.com/test'))); - $this->assertEquals(array('src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('width' => 'test', 'src' => 'http://www.youtube.com/test'))); + $this->assertEquals(array('width' => '10', 'src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('width' => '10', 'src' => 'http://www.youtube.com/test'))); + $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('width' => 'test', 'src' => 'http://www.youtube.com/test'))); } public function testRewriteProxyImageUrl() @@ -125,7 +125,7 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase $this->assertFalse($filter->filterIframeAttribute('iframe', 'src', '//www.youtube.com/test')); $this->assertFalse($filter->filterIframeAttribute('iframe', 'src', '//www.bidule.com/test')); - $this->assertEquals(array('src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test'))); + $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test'))); } public function testFilterBlacklistAttribute() diff --git a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php index bfcb8d970..f5f98a96b 100644 --- a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php @@ -71,10 +71,11 @@ class FilterTest extends PHPUnit_Framework_TestCase public function testOverrideFilters() { $data = '<iframe src="http://www.kickstarter.com/projects/lefnire/habitrpg-mobile/widget/video.html" height="480" width="640" frameborder="0"></iframe>'; + $expected = '<iframe src="https://www.kickstarter.com/projects/lefnire/habitrpg-mobile/widget/video.html" height="480" width="640" frameborder="0"></iframe>'; $f = Filter::html($data, 'http://blabla'); $f->attribute->setIframeWhitelist(array('http://www.kickstarter.com')); - $this->assertEquals($data, $f->execute()); + $this->assertEquals($expected, $f->execute()); $data = '<iframe src="http://www.youtube.com/bla" height="480" width="640" frameborder="0"></iframe>'; @@ -90,7 +91,7 @@ class FilterTest extends PHPUnit_Framework_TestCase $this->assertEquals('<p>Testboo</p>', $f->execute()); } - public function testImageProxy() + public function testNoImageProxySet() { $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo'); @@ -98,10 +99,71 @@ class FilterTest extends PHPUnit_Framework_TestCase '<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() + ); + } - // Test setFilterImageProxyUrl and HTTPS + 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); @@ -110,20 +172,40 @@ class FilterTest extends PHPUnit_Framework_TestCase '<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() + ); + } - // Test setFilterImageProxyUrl + public function testImageProxyLimitedToHTTPSwithHTTPSLink() + { $config = new Config; $config->setFilterImageProxyUrl('http://myproxy/?url=%s'); + $config->setFilterImageProxyProtocol('https'); - $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo'); + $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('http://foo/image.png').'" alt="My Image"/></p>', + '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>', $f->execute() ); + } - // Test setFilterImageProxyCallback + public function testsetFilterImageProxyCallback() + { $config = new Config; $config->setFilterImageProxyCallback(function ($image_url) { $key = hash_hmac('sha1', $image_url, 'secret'); diff --git a/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php index 271167481..5093855d1 100644 --- a/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php @@ -25,9 +25,10 @@ class HtmlFilterTest extends PHPUnit_Framework_TestCase $this->assertEmpty($f->execute()); $data = '<iframe src="http://www.youtube.com/bla" height="480" width="640" frameborder="0"></iframe>'; + $expected = '<iframe src="https://www.youtube.com/bla" height="480" width="640" frameborder="0"></iframe>'; $f = new Html($data, 'http://blabla'); - $this->assertEquals($data, $f->execute()); + $this->assertEquals($expected, $f->execute()); } public function testEmptyTags() @@ -50,7 +51,7 @@ EOD; $data = '<iframe src="http://www.youtube.com/bla" height="480px" width="100%" frameborder="0"></iframe>'; $f = new Html($data, 'http://blabla'); - $this->assertEquals('<iframe src="http://www.youtube.com/bla" frameborder="0"></iframe>', $f->execute()); + $this->assertEquals('<iframe src="https://www.youtube.com/bla" frameborder="0"></iframe>', $f->execute()); } public function testRelativeScheme() diff --git a/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php b/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php index df648ce7c..6ad464bf3 100644 --- a/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php @@ -32,17 +32,17 @@ class DateParserTest extends PHPUnit_Framework_TestCase $this->assertEquals('2010-08-20', date('Y-m-d', $parser->getTimestamp('2010-08-20Thh:08:ssZ'))); $this->assertEquals(1288648057, $parser->getTimestamp('Mon, 01 Nov 2010 21:47:37 UT')); $this->assertEquals(1346069615, $parser->getTimestamp('Mon Aug 27 2012 12:13:35 GMT-0700 (PDT)')); - $this->assertEquals(time(), $parser->getTimestamp('Tue, 3 Febuary 2010 00:00:00 IST')); - $this->assertEquals(time(), $parser->getTimestamp('############# EST')); - $this->assertEquals(time(), $parser->getTimestamp('Wed, 30 Nov -0001 00:00:00 +0000')); - $this->assertEquals(time(), $parser->getTimestamp('čet, 24 maj 2012 00:00:00')); - $this->assertEquals(time(), $parser->getTimestamp('-0-0T::Z')); - $this->assertEquals(time(), $parser->getTimestamp('Wed, 18 2012')); - $this->assertEquals(time(), $parser->getTimestamp("'2009-09-30 CDT16:09:54")); - $this->assertEquals(time(), $parser->getTimestamp('ary 8 Jan 2013 00:00:00 GMT')); - $this->assertEquals(time(), $parser->getTimestamp('Sat, 11 00:00:01 GMT')); + $this->assertEquals(time(), $parser->getTimestamp('Tue, 3 Febuary 2010 00:00:00 IST'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('############# EST'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('Wed, 30 Nov -0001 00:00:00 +0000'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('čet, 24 maj 2012 00:00:00'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('-0-0T::Z'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('Wed, 18 2012'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp("'2009-09-30 CDT16:09:54"), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('ary 8 Jan 2013 00:00:00 GMT'), '', 1); + $this->assertEquals(time(), $parser->getTimestamp('Sat, 11 00:00:01 GMT'), '', 1); $this->assertEquals(1370631743, $parser->getTimestamp('Fri Jun 07 2013 19:02:23 GMT+0000 (UTC)')); $this->assertEquals(1377412225, $parser->getTimestamp('25/08/2013 06:30:25 م')); - $this->assertEquals(time(), $parser->getTimestamp('+0400')); + $this->assertEquals(time(), $parser->getTimestamp('+0400'), '', 1); } } diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php index c282ad372..344917d27 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php @@ -93,7 +93,7 @@ class Rss20ParserTest extends PHPUnit_Framework_TestCase $parser = new Rss20(file_get_contents('tests/fixtures/fulltextrss.xml')); $feed = $parser->execute(); - $this->assertEquals(time(), $feed->getDate()); + $this->assertEquals(time(), $feed->getDate(), '', 1); } public function testFeedLanguage() @@ -259,9 +259,5 @@ class Rss20ParserTest extends PHPUnit_Framework_TestCase $parser = new Rss20(file_get_contents('tests/fixtures/jeux-linux.fr.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - - $parser = new Rss20(file_get_contents('tests/fixtures/cercle.psy.xml')); - $feed = $parser->execute(); - $this->assertNotEmpty($feed->items); } } diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php index f84a0d0d0..111f44993 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php @@ -18,13 +18,13 @@ class Rss91ParserTest extends PHPUnit_Framework_TestCase $this->assertEquals('', $feed->getFeedUrl()); $this->assertEquals('http://writetheweb.com/', $feed->getSiteUrl()); $this->assertEquals('http://writetheweb.com/', $feed->getId()); - $this->assertEquals(time(), $feed->getDate()); + $this->assertEquals(time(), $feed->getDate(), '', 1); $this->assertEquals(6, count($feed->items)); $this->assertEquals('Giving the world a pluggable Gnutella', $feed->items[0]->getTitle()); $this->assertEquals('http://writetheweb.com/read.php?item=24', $feed->items[0]->getUrl()); $this->assertEquals('085a9133a75542f878fa73ee2afbb6a2350b6c4fb125e6d8ca09478c47702111', $feed->items[0]->getId()); - $this->assertEquals(time(), $feed->items[0]->getDate()); + $this->assertEquals(time(), $feed->items[0]->getDate(), '', 1); $this->assertEquals('webmaster@writetheweb.com', $feed->items[0]->getAuthor()); $this->assertTrue(strpos($feed->items[1]->getContent(), '<p>After a period of dormancy') === 0); } diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php index 521cd7b05..d5358dd5e 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php @@ -18,7 +18,7 @@ class Rss92ParserTest extends PHPUnit_Framework_TestCase $this->assertEquals('', $feed->getFeedUrl()); $this->assertEquals('http://www.universfreebox.com/', $feed->getSiteUrl()); $this->assertEquals('http://www.universfreebox.com/', $feed->getId()); - $this->assertEquals(time(), $feed->date); + $this->assertEquals(time(), $feed->date, '', 1); $this->assertEquals(30, count($feed->items)); $this->assertEquals('Retour de Xavier Niel sur Twitter, « sans initiative privée, pas de révolution #Born2code »', $feed->items[0]->title); diff --git a/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php b/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php index b20b3f635..87bd9da3c 100644 --- a/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php @@ -13,6 +13,7 @@ class XmlParserTest extends PHPUnit_Framework_TestCase $this->assertEquals('utf-8', XmlParser::getEncodingFromXmlTag("<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet")); $this->assertEquals('utf-8', XmlParser::getEncodingFromXmlTag('<?xml version="1.0" encoding="UTF-8"?><feed xml:')); $this->assertEquals('windows-1251', XmlParser::getEncodingFromXmlTag('<?xml version="1.0" encoding="Windows-1251"?><rss version="2.0">')); + $this->assertEquals('', XmlParser::getEncodingFromXmlTag("<?xml version='1.0'?><?xml-stylesheet")); } public function testScanForXEE() |