diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-07 12:32:05 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-07 12:32:05 +0100 |
commit | 7f81afd7efbeb931d16ce1f3a1ed53a54226d553 (patch) | |
tree | 180720cd96aa66ae8964f13734e090d4b82a178e /vendor/fguillot/picofeed/tests | |
parent | a6d6288e65aa416aca7535e81d9e8837c2cfb103 (diff) |
move 3rdparty directory to vendor to be more consistent with composer standard and because we also use js/vendor for third party libs
Diffstat (limited to 'vendor/fguillot/picofeed/tests')
62 files changed, 50265 insertions, 0 deletions
diff --git a/vendor/fguillot/picofeed/tests/Client/ClientTest.php b/vendor/fguillot/picofeed/tests/Client/ClientTest.php new file mode 100644 index 000000000..98a963644 --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Client/ClientTest.php @@ -0,0 +1,83 @@ +<?php +namespace PicoFeed\Client; + +use PHPUnit_Framework_TestCase; + + +class ClientTest extends PHPUnit_Framework_TestCase +{ + public function testDownload() + { + $client = Client::getInstance(); + $client->setUrl('http://php.net/robots.txt'); + $client->execute(); + + $this->assertTrue($client->isModified()); + $this->assertNotEmpty($client->getContent()); + $this->assertNotEmpty($client->getEtag()); + $this->assertNotEmpty($client->getLastModified()); + } + + + public function testCacheEtag() + { + $client = Client::getInstance(); + $client->setUrl('http://php.net/robots.txt'); + $client->execute(); + $etag = $client->getEtag(); + + $client = Client::getInstance(); + $client->setUrl('http://php.net/robots.txt'); + $client->setEtag($etag); + $client->execute(); + + $this->assertFalse($client->isModified()); + } + + + public function testCacheLastModified() + { + $client = Client::getInstance(); + $client->setUrl('http://miniflux.net/humans.txt'); + $client->execute(); + $lastmod = $client->getLastModified(); + + $client = Client::getInstance(); + $client->setUrl('http://miniflux.net/humans.txt'); + $client->setLastModified($lastmod); + $client->execute(); + + $this->assertFalse($client->isModified()); + } + + + public function testCacheBoth() + { + $client = Client::getInstance(); + $client->setUrl('http://miniflux.net/humans.txt'); + $client->execute(); + $lastmod = $client->getLastModified(); + $etag = $client->getEtag(); + + $client = Client::getInstance(); + $client->setUrl('http://miniflux.net/humans.txt'); + $client->setLastModified($lastmod); + $client->setEtag($etag); + $client->execute(); + + $this->assertFalse($client->isModified()); + } + + public function testCharset() + { + $client = Client::getInstance(); + $client->setUrl('http://php.net/'); + $client->execute(); + $this->assertEquals('utf-8', $client->getEncoding()); + + $client = Client::getInstance(); + $client->setUrl('http://php.net/robots.txt'); + $client->execute(); + $this->assertEquals('', $client->getEncoding()); + } +}
\ No newline at end of file diff --git a/vendor/fguillot/picofeed/tests/Client/CurlTest.php b/vendor/fguillot/picofeed/tests/Client/CurlTest.php new file mode 100644 index 000000000..668816036 --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Client/CurlTest.php @@ -0,0 +1,53 @@ +<?php +namespace PicoFeed\Client; + +use PHPUnit_Framework_TestCase; + + +class CurlTest extends PHPUnit_Framework_TestCase +{ + public function testDownload() + { + $client = new Curl; + $client->setUrl('http://miniflux.net/index.html'); + $result = $client->doRequest(); + + $this->assertTrue(is_array($result)); + $this->assertEquals(200, $result['status']); + $this->assertEquals('<!DOC', substr($result['body'], 0, 5)); + $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); + } + + + public function testRedirect() + { + $client = new Curl; + $client->setUrl('http://www.miniflux.net/index.html'); + $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']); + } + + /** + * @expectedException PicoFeed\Client\InvalidCertificateException + */ + public function testSSL() + { + $client = new Curl; + $client->setUrl('https://www.mjvmobile.com.br'); + $client->doRequest(); + } + + /** + * @expectedException PicoFeed\Client\InvalidUrlException + */ + public function testBadUrl() + { + $client = new Curl; + $client->setUrl('http://12345gfgfgf'); + $client->doRequest(); + } +}
\ No newline at end of file diff --git a/vendor/fguillot/picofeed/tests/Client/FaviconTest.php b/vendor/fguillot/picofeed/tests/Client/FaviconTest.php new file mode 100644 index 000000000..c0ac11ac6 --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Client/FaviconTest.php @@ -0,0 +1,143 @@ +<?php +namespace PicoFeed\Client; + +use PHPUnit_Framework_TestCase; + + +class FaviconTest extends PHPUnit_Framework_TestCase +{ + public function testExtract() + { + $favicon = new Favicon; + + $html = '<!DOCTYPE html><html><head> + <link rel="shortcut icon" href="http://example.com/myicon.ico" /> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/myicon.ico'), $favicon->extract($html)); + + $html = '<!DOCTYPE html><html><head> + <link rel="icon" href="http://example.com/myicon.ico" /> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/myicon.ico'), $favicon->extract($html)); + + $html = '<!DOCTYPE html><html><head> + <link rel="icon" type="image/vnd.microsoft.icon" href="http://example.com/image.ico" /> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/image.ico'), $favicon->extract($html)); + + $html = '<!DOCTYPE html><html><head> + <link rel="icon" type="image/png" href="http://example.com/image.png" /> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/image.png'), $favicon->extract($html)); + + $html = '<!DOCTYPE html><html><head> + <link rel="icon" type="image/gif" href="http://example.com/image.gif" /> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/image.gif'), $favicon->extract($html)); + + $html = '<!DOCTYPE html><html><head> + <link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/image.ico'), $favicon->extract($html)); + + $html = '<!DOCTYPE html><html><head> + <link rel="apple-touch-icon" href="assets/img/touch-icon-iphone.png"> + <link rel="icon" type="image/png" href="http://example.com/image.png" /> + <link rel="icon" type="image/x-icon" href="http://example.com/image.ico"/> + </head><body><p>boo</p></body></html>'; + + $this->assertEquals(array('http://example.com/image.png', 'http://example.com/image.ico'), $favicon->extract($html)); + } +/* + public function testHasFile() + { + $favicon = new Favicon; + $this->assertTrue($favicon->exists('https://en.wikipedia.org/favicon.ico')); + $this->assertFalse($favicon->exists('http://minicoders.com/favicon.ico')); + $this->assertFalse($favicon->exists('http://blabla')); + } +*/ + public function testConvertLink() + { + $favicon = new Favicon; + + $this->assertEquals( + 'http://miniflux.net/assets/img/favicon.png', + $favicon->convertLink(new Url('http://miniflux.net'), new Url('assets/img/favicon.png')) + ); + + $this->assertEquals( + 'https://miniflux.net/assets/img/favicon.png', + $favicon->convertLink(new Url('https://miniflux.net'), new Url('assets/img/favicon.png')) + ); + + $this->assertEquals( + 'http://google.com/assets/img/favicon.png', + $favicon->convertLink(new Url('http://miniflux.net'), new Url('//google.com/assets/img/favicon.png')) + ); + + $this->assertEquals( + 'https://google.com/assets/img/favicon.png', + $favicon->convertLink(new Url('https://miniflux.net'), new Url('//google.com/assets/img/favicon.png')) + ); + } + + public function testFind() + { + $favicon = new Favicon; + + // Relative favicon in html + $this->assertEquals( + 'http://miniflux.net/assets/img/favicon.png', + $favicon->find('http://miniflux.net') + ); + + $this->assertNotEmpty($favicon->getContent()); + + // Absolute html favicon + $this->assertEquals( + 'http://php.net/favicon.ico', + $favicon->find('http://php.net/parse_url') + ); + + $this->assertNotEmpty($favicon->getContent()); + + // Protocol relative favicon + $this->assertEquals( + 'https://bits.wikimedia.org/favicon/wikipedia.ico', + $favicon->find('https://en.wikipedia.org/') + ); + + $this->assertNotEmpty($favicon->getContent()); + + // fluid-icon + https + $this->assertEquals( + 'https://github.com/fluidicon.png', + $favicon->find('https://github.com') + ); + + $this->assertNotEmpty($favicon->getContent()); + + // favicon in meta + $this->assertEquals( + 'http://www.microsoft.com/favicon.ico?v2', + $favicon->find('http://www.microsoft.com') + ); + + $this->assertNotEmpty($favicon->getContent()); + + // no icon + $this->assertEquals( + '', + $favicon->find('http://minicoders.com/favicon.ico') + ); + + $this->assertEmpty($favicon->getContent()); + } +} diff --git a/vendor/fguillot/picofeed/tests/Client/GrabberTest.php b/vendor/fguillot/picofeed/tests/Client/GrabberTest.php new file mode 100644 index 000000000..5aec5ca11 --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Client/GrabberTest.php @@ -0,0 +1,60 @@ +<?php +namespace PicoFeed\Client; + +use PHPUnit_Framework_TestCase; + +use PicoFeed\Reader\Reader; +use PicoFeed\Logging\Logging; + +class GrabberTest extends PHPUnit_Framework_TestCase +{ + public function testGrabContentWithCandidates() + { + $grabber = new Grabber('http://theonion.com.feedsportal.com/c/34529/f/632231/s/309a7fe4/sc/20/l/0L0Stheonion0N0Carticles0Cobama0Ethrows0Eup0Eright0Ethere0Eduring0Esyria0Emeeting0H336850C/story01.htm'); + $grabber->download(); + $this->assertTrue($grabber->parse()); + + $grabber = new Grabber('http://www.lemonde.fr/proche-orient/article/2013/08/30/la-france-nouvelle-plus-ancienne-alliee-des-etats-unis_3469218_3218.html'); + $grabber->download(); + $this->assertTrue($grabber->parse()); + + $grabber = new Grabber('http://www.rue89.com/2013/08/30/faisait-boris-boillon-ex-sarko-boy-350-000-euros-gare-nord-245315'); + $grabber->download(); + $this->assertTrue($grabber->parse()); + + $grabber = new Grabber('http://www.inc.com/suzanne-lucas/why-employee-turnover-is-so-costly.html'); + $grabber->download(); + $this->assertTrue($grabber->parse()); + + $grabber = new Grabber('http://arstechnica.com/information-technology/2013/08/sysadmin-security-fail-nsa-finds-snowden-hijacked-officials-logins/'); + $grabber->download(); + $this->assertTrue($grabber->parse()); + } + + public function testGetRules() + { + $grabber = new Grabber('http://www.egscomics.com/index.php?id=1690'); + $this->assertTrue(is_array($grabber->getRules())); + } + + public function testGrabContent() + { + $grabber = new Grabber('http://www.egscomics.com/index.php?id=1690'); + $grabber->download(); + $this->assertTrue($grabber->parse()); + + $this->assertEquals('<img title="2013-08-22" src="comics/../comics/1377151029-2013-08-22.png" id="comic" border="0" />', $grabber->getContent()); + } + + public function testRssGrabContent() + { + $reader = new Reader; + $client = $reader->download('http://www.egscomics.com/rss.php'); + $parser = $reader->getParser($client->getUrl(), $client->getContent(), $client->getEncoding()); + $parser->enableContentGrabber(); + $feed = $parser->execute(); + + $this->assertTrue(is_array($feed->items)); + $this->assertTrue(strpos($feed->items[0]->content, '<img') >= 0); + } +} diff --git a/vendor/fguillot/picofeed/tests/Client/StreamTest.php b/vendor/fguillot/picofeed/tests/Client/StreamTest.php new file mode 100644 index 000000000..8b2e2f8b8 --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Client/StreamTest.php @@ -0,0 +1,63 @@ +<?php +namespace PicoFeed\Client; + +use PHPUnit_Framework_TestCase; + + +class StreamTest extends PHPUnit_Framework_TestCase +{ + public function testChunkedResponse() + { + $client = new Stream; + $client->setUrl('http://www.reddit.com/r/dwarffortress/.rss'); + $result = $client->doRequest(); + + $this->assertEquals('</rss>', substr($result['body'], -6)); + } + + public function testDownload() + { + $client = new Stream; + $client->setUrl('https://github.com/fguillot/picoFeed'); + $result = $client->doRequest(); + + $this->assertEquals(200, $result['status']); + $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); + $this->assertEquals('<!DOCTYPE html>', substr(trim($result['body']), 0, 15)); + $this->assertEquals('</html>', substr(trim($result['body']), -7)); + } + + public function testRedirect() + { + $client = new Stream; + $client->setUrl('http://github.com/fguillot/picoFeed'); + $result = $client->doRequest(); + + $this->assertEquals(200, $result['status']); + $this->assertEquals('<!DOCTYPE html>', substr(trim($result['body']), 0, 15)); + $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); + } + + /** + * @expectedException PicoFeed\Client\InvalidUrlException + */ |