summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/tests/Client
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/picofeed/tests/Client')
-rw-r--r--vendor/fguillot/picofeed/tests/Client/ClientTest.php145
-rw-r--r--vendor/fguillot/picofeed/tests/Client/CurlTest.php74
-rw-r--r--vendor/fguillot/picofeed/tests/Client/HttpHeadersTest.php19
-rw-r--r--vendor/fguillot/picofeed/tests/Client/StreamTest.php91
-rw-r--r--vendor/fguillot/picofeed/tests/Client/UrlTest.php298
5 files changed, 0 insertions, 627 deletions
diff --git a/vendor/fguillot/picofeed/tests/Client/ClientTest.php b/vendor/fguillot/picofeed/tests/Client/ClientTest.php
deleted file mode 100644
index 4099a7158..000000000
--- a/vendor/fguillot/picofeed/tests/Client/ClientTest.php
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php
-
-namespace PicoFeed\Client;
-
-use PHPUnit_Framework_TestCase;
-
-class ClientTest extends PHPUnit_Framework_TestCase
-{
- /**
- * @group online
- */
- 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());
- }
-
- /**
- * @runInSeparateProcess
- * @group online
- */
- public function testPassthrough()
- {
- $client = Client::getInstance();
- $client->setUrl('https://miniflux.net/favicon.ico');
- $client->enablePassthroughMode();
- $client->execute();
-
- $this->expectOutputString(file_get_contents('tests/fixtures/miniflux_favicon.ico'));
- }
-
- /**
- * @group online
- */
- public function testCacheBothHaveToMatch()
- {
- $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->assertTrue($client->isModified());
- }
-
- /**
- * @group online
- */
- public function testCacheEtag()
- {
- $client = Client::getInstance();
- $client->setUrl('http://php.net/robots.txt');
- $client->execute();
- $etag = $client->getEtag();
- $lastModified = $client->getLastModified();
-
- $client = Client::getInstance();
- $client->setUrl('http://php.net/robots.txt');
- $client->setEtag($etag);
- $client->setLastModified($lastModified);
- $client->execute();
-
- $this->assertFalse($client->isModified());
- }
-
- /**
- * @group online
- */
- 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());
- }
-
- /**
- * @group online
- */
- 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());
- }
-
- /**
- * @group online
- */
- 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());
- }
-
- /**
- * @group online
- */
- public function testContentType()
- {
- $client = Client::getInstance();
- $client->setUrl('http://miniflux.net/assets/img/favicon.png');
- $client->execute();
- $this->assertEquals('image/png', $client->getContentType());
-
- $client = Client::getInstance();
- $client->setUrl('http://miniflux.net/');
- $client->execute();
- $this->assertEquals('text/html; charset=utf-8', $client->getContentType());
- }
-}
diff --git a/vendor/fguillot/picofeed/tests/Client/CurlTest.php b/vendor/fguillot/picofeed/tests/Client/CurlTest.php
deleted file mode 100644
index ec7b39894..000000000
--- a/vendor/fguillot/picofeed/tests/Client/CurlTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-namespace PicoFeed\Client;
-
-use PHPUnit_Framework_TestCase;
-
-
-class CurlTest extends PHPUnit_Framework_TestCase
-{
- /**
- * @group online
- */
- 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']);
- }
-
- /**
- * @runInSeparateProcess
- * @group online
- */
- public function testPassthrough()
- {
- $client = new Curl;
- $client->setUrl('https://miniflux.net/favicon.ico');
- $client->enablePassthroughMode();
- $client->doRequest();
-
- $this->expectOutputString(file_get_contents('tests/fixtures/miniflux_favicon.ico'));
- }
-
- /**
- * @group online
- */
- public function testRedirect()
- {
- $client = new Curl;
- $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://www.01net.com/actualites/android-google-now-s-ouvre-aux-applications-tierces-643722.html', $client->getUrl());
- }
-
- /**
- * @expectedException PicoFeed\Client\InvalidCertificateException
- * @group online
- */
- 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/HttpHeadersTest.php b/vendor/fguillot/picofeed/tests/Client/HttpHeadersTest.php
deleted file mode 100644
index f577d00fa..000000000
--- a/vendor/fguillot/picofeed/tests/Client/HttpHeadersTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-namespace PicoFeed\Client;
-
-use PHPUnit_Framework_TestCase;
-
-
-class HttpHeadersTest extends PHPUnit_Framework_TestCase
-{
-
- public function testHttpHeadersSet() {
- $headers = new HttpHeaders(array('Content-Type' => 'test'));
- $this->assertEquals('test', $headers['content-typE']);
- $this->assertTrue(isset($headers['ConTent-Type']));
-
- unset($headers['Content-Type']);
- $this->assertFalse(isset($headers['ConTent-Type']));
- }
-
-} \ No newline at end of file
diff --git a/vendor/fguillot/picofeed/tests/Client/StreamTest.php b/vendor/fguillot/picofeed/tests/Client/StreamTest.php
deleted file mode 100644
index 764850d3c..000000000
--- a/vendor/fguillot/picofeed/tests/Client/StreamTest.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-namespace PicoFeed\Client;
-
-use PHPUnit_Framework_TestCase;
-
-
-class StreamTest extends PHPUnit_Framework_TestCase
-{
- /**
- * @group online
- */
- 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));
- }
-
- /**
- * @group online
- */
- 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));
- }
-
- /**
- * @runInSeparateProcess
- * @group online
- */
- public function testPassthrough()
- {
- $client = new Stream;
- $client->setUrl('http://miniflux.net/favicon.ico');
- $client->enablePassthroughMode();
- $client->doRequest();
-
- $this->expectOutputString(file_get_contents('tests/fixtures/miniflux_favicon.ico'));
- }
-
- /**
- * @group online
- */
- public function testRedirect()
- {
- $client = new Stream;
- $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://www.01net.com/actualites/android-google-now-s-ouvre-aux-applications-tierces-643722.html', $client->getUrl());
- }
-
- /**
- * @expectedException PicoFeed\Client\InvalidUrlException
- */
- public function testBadUrl()
- {
- $client = new Stream;
- $client->setUrl('http://12345gfgfgf');
- $client->setTimeout(1);
- $client->doRequest();
- }
-
- /**
- * @group online
- */
- public function testDecodeGzip()
- {
- if (function_exists('gzdecode')) {
- $client = new Stream;
- $client->setUrl('https://github.com/fguillot/picoFeed');
- $result = $client->doRequest();
-
- $this->assertEquals('gzip', $result['headers']['Content-Encoding']);
- $this->assertEquals('<!DOC', substr(trim($result['body']), 0, 5));
- }
- }
-} \ No newline at end of file
diff --git a/vendor/fguillot/picofeed/tests/Client/UrlTest.php b/vendor/fguillot/picofeed/tests/Client/UrlTest.php
deleted file mode 100644
index e74e0c79d..000000000
--- a/vendor/fguillot/picofeed/tests/Client/UrlTest.php
+++ /dev/null
@@ -1,298 +0,0 @@
-<?php
-
-namespace PicoFeed\Client;
-
-use PHPUnit_Framework_TestCase;
-
-class UrlTest extends PHPUnit_Framework_TestCase
-{
- public function testHasScheme()
- {
- $url = new Url('http://www.google.fr/');
- $this->assertTrue($url->hasScheme());
-
- $url = new Url('//www.google.fr/');
- $this->assertFalse($url->hasScheme());
-
- $url = new Url('/path');
- $this->assertFalse($url->hasScheme());
-
- $url = new Url('anything');
- $this->assertFalse($url->hasScheme());
- }
-
- public function testHasPort()
- {
- $url = new Url('http://127.0.0.1:8000/');
- $this->assertTrue($url->hasPort());
-
- $url = new Url('http://127.0.0.1/');
- $this->assertFalse($url->hasPort());
- }
-
- public function testIsProtocolRelative()
- {
- $url = new Url('http://www.google.fr/');
- $this->assertFalse($url->isProtocolRelative());
-
- $url = new Url('//www.google.fr/');
- $this->assertTrue($url->isProtocolRelative());
-
- $url = new Url('/path');
- $this->assertFalse($url->isProtocolRelative());
-
- $url = new Url('anything');
- $this->assertFalse($url->isProtocolRelative());
- }
-
- public function testBaseUrl()
- {
- $url = new Url('../bla');
- $this->assertEquals('', $url->getBaseUrl());
-
- $url = new Url('github.com');
- $this->assertEquals('', $url->getBaseUrl());
-
- $url = new Url('http://127.0.0.1:8000');
- $this->assertEquals('http://127.0.0.1:8000', $url->getBaseUrl());
-
- $url = new Url('http://127.0.0.1:8000/test?123');
- $this->assertEquals('http://127.0.0.1:8000', $url->getBaseUrl());
-
- $url = new Url('http://localhost/test');
- $this->assertEquals('http://localhost', $url->getBaseUrl());
-
- $url = new Url('https://localhost/test');
- $this->assertEquals('https://localhost', $url->getBaseUrl());
-
- $url = new Url('//localhost/test?truc');
- $this->assertEquals('http://localhost', $url->getBaseUrl());
-
- $url = new Url('//localhost/test?truc');
- $this->assertEquals('http://localhost', $url->getBaseUrl());
- }
-
- public function testIsRelativeUrl()
- {
- $url = new Url('http://www.google.fr/');
- $this->assertFalse($url->isRelativeUrl());
-
- $url = new Url('//www.google.fr/');
- $this->assertFalse($url->isRelativeUrl());
-
- $url = new Url('/path');
- $this->assertTrue($url->isRelativeUrl());
-
- $url = new Url('../../path');
- $this->assertTrue($url->isRelativeUrl());
-
- $url = new Url('anything');
- $this->assertTrue($url->isRelativeUrl());
-
- $url = new Url('/2014/08/03/4668-noisettes');
- $this->assertTrue($url->isRelativeUrl());
-
- $url = new Url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
-AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
-9TXL0Y4OHwAAAABJRU5ErkJggg==');
- $this->assertFalse($url->isRelativeUrl());
- }
-
- public function testGetFullPath()
- {
- $url = new Url('http://www.google.fr/');
- $this->assertEquals('/', $url->getFullPath());
-
- $url = new Url('//www.google.fr/search');
- $this->assertEquals('/search', $url->getFullPath());
-
- $url = new Url('/path');
- $this->assertEquals('/path', $url->getFullPath());
-
- $url = new Url('/path#test');
- $this->assertEquals('/path#test', $url->getFullPath());
-
- $url = new Url('anything');
- $this->assertEquals('/anything', $url->getFullPath());
-
- $url = new Url('foo/bar');
- $this->assertEquals('/foo/bar', $url->getFullPath());
-
- $url = new Url('index.php?foo=bar&test=1');
- $this->assertEquals('/index.php?foo=bar&test=1', $url->getFullPath());
- }
-
- public function testAbsoluteUrl()
- {
- $url = new Url('http://google.fr/');
- $this->assertEquals('http://google.fr/', $url->getAbsoluteUrl());
-
- $url = new Url('http://google.ca');
- $this->assertEquals('http://google.ca/', $url->getAbsoluteUrl());
-
- $url = new Url('../bla');
- $this->assertEquals('', $url->getAbsoluteUrl(''));
-
- $url = new Url('/2014/08/03/4668-noisettes');
- $this->assertEquals('http://www.la-grange.net/2014/08/03/4668-noisettes', $url->getAbsoluteUrl('http://www.la-grange.net/'));
-
- $url = new Url('http://www.google.fr/../bla');
- $this->assertEquals('http://www.google.fr/../bla', $url->getAbsoluteUrl('http://www.google.fr/'));
-
- $url = new Url('http://www.google.fr/');
- $this->assertEquals('http://www.google.fr/', $url->getAbsoluteUrl('http://www.google.fr/'));
-
- $url = new Url('//www.google.fr/search');
- $this->assertEquals('http://www.google.fr/search', $url->getAbsoluteUrl('//www.google.fr/'));
-
- $url = new Url('//www.google.fr/search');
- $this->assertEquals('http://www.google.fr/search', $url->getAbsoluteUrl());
-
- $url = new Url('/path');
- $this->assertEquals('http://www.google.fr/path', $url->getAbsoluteUrl('http://www.google.fr/'));
-
- $url = new Url('/path#test');
- $this->assertEquals('http://www.google.fr/path#test', $url->getAbsoluteUrl('http://www.google.fr/'));
-
- $url = new Url('anything');
- $this->assertEquals('http://www.google.fr/anything', $url->getAbsoluteUrl('http://www.google.fr/'));
-
- $url = new Url('index.php?foo=bar&test=1');
- $this->assertEquals('http://www.google.fr/index.php?foo=bar&test=1', $url->getAbsoluteUrl('http://www.google.fr/'));
-
- $url = new Url('index.php?foo=bar&test=1');
- $this->assertEquals('', $url->getAbsoluteUrl());
-
- $url = new Url('https://127.0.0.1:8000/here/test?v=3');
- $this->assertEquals('https://127.0.0.1:8000/here/test?v=3', $url->getAbsoluteUrl());
-
- $url = new Url('http://www.lofibucket.com/articles/oscilloscope_quake.html');
- $this->assertEquals('http://www.lofibucket.com/articles/oscilloscope_quake.html', $url->getAbsoluteUrl());
-
- $url = new Url('test?v=3');
- $this->assertEquals('https://127.0.0.1:8000/here/test?v=3', $url->getAbsoluteUrl('https://127.0.0.1:8000/here/'));
- }
-
- public function testIsRelativePath()
- {
- $url = new Url('');
- $this->assertTrue($url->isRelativePath());
-
- $url = new Url('http://google.fr');
- $this->assertTrue($url->isRelativePath());
-
- $url = new Url('filename.json');
- $this->assertTrue($url->isRelativePath());
-
- $url = new Url('folder/filename.json');
- $this->assertTrue($url->isRelativePath());
-
- $url = new Url('/filename.json');
- $this->assertFalse($url->isRelativePath());
-
- $url = new Url('/folder/filename.json');
- $this->assertFalse($url->isRelativePath());
- }
-
- public function testGetBasePath()
- {
- $url = new Url('img/quakescope.jpg');
- $this->assertEquals('/img/', $url->getBasePath());
-
- $url = new Url('http://foo/img/quakescope.jpg');
- $this->assertEquals('/img/', $url->getBasePath());
-
- $url = new Url('http://foo/bar.html');
- $this->assertEquals('/', $url->getBasePath());
-
- $url = new Url('http://foo/bar');
- $this->assertEquals('/', $url->getBasePath());
-
- $url = new Url('http://foo/bar/');
- $this->assertEquals('/bar/', $url->getBasePath());
-
- $url = new Url('http://website/subfolder/img/foo.png');
- $this->assertEquals('/subfolder/img/', $url->getBasePath());
- }
-
- public function testResolve()
- {
- // relative link
- $this->assertEquals(
- 'http://miniflux.net/assets/img/favicon.png',
- Url::resolve('assets/img/favicon.png', 'http://miniflux.net')
- );
-
- // relative link + HTTPS
- $this->assertEquals(
- 'https://miniflux.net/assets/img/favicon.png',
- Url::resolve('assets/img/favicon.png', 'https://miniflux.net')
- );
-
- // absolute link
- $this->assertEquals(
- 'http://miniflux.net/assets/img/favicon.png',
- Url::resolve('/assets/img/favicon.png', 'http://miniflux.net')
- );
-
- // absolute link + HTTPS
- $this->assertEquals(
- 'https://miniflux.net/assets/img/favicon.png',
- Url::resolve('/assets/img/favicon.png', 'https://miniflux.net')
- );
-
- // Protocol relative link
- $this->assertEquals(
- 'http://google.com/assets/img/favicon.png',
- Url::resolve('//google.com/assets/img/favicon.png', 'http://miniflux.net')
- );
-
- // Protocol relative link + HTTPS
- $this->assertEquals(
- 'https://google.com/assets/img/favicon.png',
- Url::resolve('//google.com/assets/img/favicon.png', 'https://miniflux.net')
- );
-
- // URL same fqdn
- $this->assertEquals(
- 'http://miniflux.net/assets/img/favicon.png',
- Url::resolve('http://miniflux.net/assets/img/favicon.png', 'https://miniflux.net')
- );
-
- // URL different fqdn
- $this->assertEquals(
- 'https://www.google.com/assets/img/favicon.png',
- Url::resolve('https://www.google.com/assets/img/favicon.png', 'https://miniflux.net')
- );
-
- // HTTPS URL
- $this->assertEquals(
- 'https://miniflux.net/assets/img/favicon.png',
- Url::resolve('https://miniflux.net/assets/img/favicon.png', 'https://miniflux.net')
- );
-
- // empty string on missing website parameter
- $this->assertEquals(
- '',
- Url::resolve('favicon.png', '')
- );
-
- // website only on missing icon parameter
- $this->assertEquals(
- 'https://miniflux.net/',
- Url::resolve('', 'https://miniflux.net')
- );
-
- // empty string on missing website and icon parameter
- $this->assertEquals(
- '',
- Url::resolve('', '')
- );
-
- // Test no-ascii paths
- $this->assertEquals(
- 'http://lesjoiesducode.fr/post/125336534020/quand-la-page-doit-%C3%AAtre-pixel-perfect',
- Url::resolve('http://lesjoiesducode.fr/post/125336534020/quand-la-page-doit-ĂȘtre-pixel-perfect', 'http://lesjoiesducode.fr/post/125336534020')
- );
- }
-}