diff options
author | friendica <info@friendica.com> | 2012-05-12 17:57:41 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-18 20:40:31 +1000 |
commit | 7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch) | |
tree | a9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/tests/HTMLPurifier/VarParser/FlexibleTest.php | |
parent | cd727cb26b78a1dade09d510b071446898477356 (diff) | |
download | volse-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/VarParser/FlexibleTest.php')
-rw-r--r-- | lib/htmlpurifier/tests/HTMLPurifier/VarParser/FlexibleTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/VarParser/FlexibleTest.php b/lib/htmlpurifier/tests/HTMLPurifier/VarParser/FlexibleTest.php new file mode 100644 index 000000000..c6149b6b4 --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/VarParser/FlexibleTest.php @@ -0,0 +1,66 @@ +<?php + +class HTMLPurifier_VarParser_FlexibleTest extends HTMLPurifier_VarParserHarness +{ + + function testValidate() { + + $this->assertValid('foobar', 'string'); + $this->assertValid('foobar', 'text'); + $this->assertValid('FOOBAR', 'istring', 'foobar'); + $this->assertValid('FOOBAR', 'itext', 'foobar'); + + $this->assertValid(34, 'int'); + + $this->assertValid(3.34, 'float'); + + $this->assertValid(false, 'bool'); + $this->assertValid(0, 'bool', false); + $this->assertValid(1, 'bool', true); + $this->assertValid('true', 'bool', true); + $this->assertValid('false', 'bool', false); + $this->assertValid('1', 'bool', true); + $this->assertInvalid(34, 'bool'); + $this->assertInvalid(null, 'bool'); + + $this->assertValid(array('1', '2', '3'), 'list'); + $this->assertValid('foo,bar, cow', 'list', array('foo', 'bar', 'cow')); + $this->assertValid('', 'list', array()); + $this->assertValid("foo\nbar", 'list', array('foo', 'bar')); + $this->assertValid("foo\nbar,baz", 'list', array('foo', 'bar', 'baz')); + + $this->assertValid(array('1' => true, '2' => true), 'lookup'); + $this->assertValid(array('1', '2'), 'lookup', array('1' => true, '2' => true)); + $this->assertValid('foo,bar', 'lookup', array('foo' => true, 'bar' => true)); + $this->assertValid("foo\nbar", 'lookup', array('foo' => true, 'bar' => true)); + $this->assertValid("foo\nbar,baz", 'lookup', array('foo' => true, 'bar' => true, 'baz' => true)); + $this->assertValid('', 'lookup', array()); + $this->assertValid(array(), 'lookup'); + + $this->assertValid(array('foo' => 'bar'), 'hash'); + $this->assertValid(array(1 => 'moo'), 'hash'); + $this->assertInvalid(array(0 => 'moo'), 'hash'); + $this->assertValid('', 'hash', array()); + $this->assertValid('foo:bar,too:two', 'hash', array('foo' => 'bar', 'too' => 'two')); + $this->assertValid("foo:bar\ntoo:two,three:free", 'hash', array('foo' => 'bar', 'too' => 'two', 'three' => 'free')); + $this->assertValid('foo:bar,too', 'hash', array('foo' => 'bar')); + $this->assertValid('foo:bar,', 'hash', array('foo' => 'bar')); + $this->assertValid('foo:bar:baz', 'hash', array('foo' => 'bar:baz')); + + $this->assertValid(23, 'mixed'); + + } + + function testValidate_withMagicNumbers() { + $this->assertValid('foobar', HTMLPurifier_VarParser::STRING); + } + + function testValidate_null() { + $this->assertIdentical($this->parser->parse(null, 'string', true), null); + $this->expectException('HTMLPurifier_VarParserException'); + $this->parser->parse(null, 'string', false); + } + +} + +// vim: et sw=4 sts=4 |