summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/picofeed/tests/Filter/FilterTest.php')
-rw-r--r--vendor/fguillot/picofeed/tests/Filter/FilterTest.php35
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