diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-12-17 09:01:54 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-12-17 09:02:13 +0100 |
commit | 867cb7dbf960dc0cfbf7e59d656d1337bb59c526 (patch) | |
tree | 5bbdf1eef51cd3747f55ef2c524364f9cd3bf029 /vendor/fguillot/picofeed/tests/Filter/FilterTest.php | |
parent | a813b535eeb517e0ccd69a90d0058756014a1e01 (diff) |
update picofeed, fix #695
Diffstat (limited to 'vendor/fguillot/picofeed/tests/Filter/FilterTest.php')
-rw-r--r-- | vendor/fguillot/picofeed/tests/Filter/FilterTest.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php index f3b736dfb..8bbb2b97c 100644 --- a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php @@ -85,4 +85,39 @@ class FilterTest extends PHPUnit_Framework_TestCase $f->setConfig($config); $this->assertEquals('<p>Testboo</p>', $f->execute()); } + + public function testImageProxy() + { + $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() + ); + + $config = new Config; + $config->setFilterImageProxyUrl('http://myproxy/?url=%s'); + + $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo'); + $f->setConfig($config); + + $this->assertEquals( + '<p>Image <img src="http://myproxy/?url='.urlencode('http://foo/image.png').'" alt="My Image"/></p>', + $f->execute() + ); + + $config = new Config; + $config->setFilterImageProxyCallback(function ($image_url) { + $key = hash_hmac('sha1', $image_url, 'secret'); + return 'https://mypublicproxy/'.$key.'/'.urlencode($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/'.urlencode('http://foo/image.png').'" alt="My Image"/></p>', + $f->execute() + ); + } }
\ No newline at end of file |