aboutsummaryrefslogtreecommitdiffstats
path: root/lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-12 17:57:41 -0700
committerfriendica <info@friendica.com>2012-07-18 20:40:31 +1000
commit7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch)
treea9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php
parentcd727cb26b78a1dade09d510b071446898477356 (diff)
downloadvolse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.gz
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.bz2
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.zip
some important stuff we'll need
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php')
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php
new file mode 100644
index 000000000..6ab0c2a6b
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/URIDefinitionTest.php
@@ -0,0 +1,62 @@
+<?php
+
+class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
+{
+
+ protected function createFilterMock($expect = true, $result = true, $post = false, $setup = true) {
+ static $i = 0;
+ generate_mock_once('HTMLPurifier_URIFilter');
+ $mock = new HTMLPurifier_URIFilterMock();
+ if ($expect) $mock->expectOnce('filter');
+ else $mock->expectNever('filter');
+ $mock->setReturnValue('filter', $result);
+ $mock->setReturnValue('prepare', $setup);
+ $mock->name = $i++;
+ $mock->post = $post;
+ return $mock;
+ }
+
+ function test_filter() {
+ $def = new HTMLPurifier_URIDefinition();
+ $def->addFilter($this->createFilterMock(), $this->config);
+ $def->addFilter($this->createFilterMock(), $this->config);
+ $uri = $this->createURI('test');
+ $this->assertTrue($def->filter($uri, $this->config, $this->context));
+ }
+
+ function test_filter_earlyAbortIfFail() {
+ $def = new HTMLPurifier_URIDefinition();
+ $def->addFilter($this->createFilterMock(true, false), $this->config);
+ $def->addFilter($this->createFilterMock(false), $this->config); // never called
+ $uri = $this->createURI('test');
+ $this->assertFalse($def->filter($uri, $this->config, $this->context));
+ }
+
+ function test_setupMemberVariables_collisionPrecedenceIsHostBaseScheme() {
+ $this->config->set('URI.Host', $host = 'example.com');
+ $this->config->set('URI.Base', $base = 'http://sub.example.com/foo/bar.html');
+ $this->config->set('URI.DefaultScheme', 'ftp');
+ $def = new HTMLPurifier_URIDefinition();
+ $def->setup($this->config);
+ $this->assertIdentical($def->host, $host);
+ $this->assertIdentical($def->base, $this->createURI($base));
+ $this->assertIdentical($def->defaultScheme, 'http'); // not ftp!
+ }
+
+ function test_setupMemberVariables_onlyScheme() {
+ $this->config->set('URI.DefaultScheme', 'ftp');
+ $def = new HTMLPurifier_URIDefinition();
+ $def->setup($this->config);
+ $this->assertIdentical($def->defaultScheme, 'ftp');
+ }
+
+ function test_setupMemberVariables_onlyBase() {
+ $this->config->set('URI.Base', 'http://sub.example.com/foo/bar.html');
+ $def = new HTMLPurifier_URIDefinition();
+ $def->setup($this->config);
+ $this->assertIdentical($def->host, 'sub.example.com');
+ }
+
+}
+
+// vim: et sw=4 sts=4