PATH:
home
/
letacommog
/
letaweb
/
admin
/
classes
/
htmlpurifier
/
tests
/
HTMLPurifier
<?php class HTMLPurifier_LengthTest extends HTMLPurifier_Harness { public function testConstruct() { $l = new HTMLPurifier_Length('23', 'in'); $this->assertIdentical($l->getN(), '23'); $this->assertIdentical($l->getUnit(), 'in'); } public function testMake() { $l = HTMLPurifier_Length::make('+23.4in'); $this->assertIdentical($l->getN(), '+23.4'); $this->assertIdentical($l->getUnit(), 'in'); } public function testToString() { $l = new HTMLPurifier_Length('23', 'in'); $this->assertIdentical($l->toString(), '23in'); } protected function assertValidate($string, $expect = true) { if ($expect === true) { $expect = $string; } $l = HTMLPurifier_Length::make($string); $result = $l->isValid(); if ($result === false) { $this->assertIdentical($expect, false); } else { $this->assertIdentical($l->toString(), $expect); } } public function testValidate() { $this->assertValidate('0'); $this->assertValidate('+0', '0'); $this->assertValidate('-0', '0'); $this->assertValidate('0px'); $this->assertValidate('4.5px'); $this->assertValidate('-4.5px'); $this->assertValidate('3ex'); $this->assertValidate('3em'); $this->assertValidate('3in'); $this->assertValidate('3cm'); $this->assertValidate('3mm'); $this->assertValidate('3pt'); $this->assertValidate('3pc'); $this->assertValidate('3PX', '3px'); $this->assertValidate('3', false); $this->assertValidate('3miles', false); } /** * @param $s1 First string to compare * @param $s2 Second string to compare * @param $expect 0 for $s1 == $s2, 1 for $s1 > $s2 and -1 for $s1 < $s2 */ protected function assertComparison($s1, $s2, $expect = 0) { $l1 = HTMLPurifier_Length::make($s1); $l2 = HTMLPurifier_Length::make($s2); $r1 = $l1->compareTo($l2); $r2 = $l2->compareTo($l1); $this->assertIdentical($r1 == 0 ? 0 : ($r1 > 0 ? 1 : -1), $expect); $this->assertIdentical($r2 == 0 ? 0 : ($r2 > 0 ? 1 : -1), -$expect); } public function testCompareTo() { $this->assertComparison('12in', '12in'); $this->assertComparison('12in', '12mm', 1); $this->assertComparison('1px', '1mm', -1); $this->assertComparison(str_repeat('2', 38).'in', '100px', 1); } } // vim: et sw=4 sts=4
[+]
..
[+]
AttrTransform
[-] HTMLModuleTest.php
[edit]
[-] HTMLModuleManagerTest.php
[edit]
[-] VarParserHarness.php
[edit]
[-] EntityParserTest.php
[edit]
[-] HTMLT.php
[edit]
[-] IDAccumulatorTest.php
[edit]
[-] LengthTest.php
[edit]
[-] ChildDefHarness.php
[edit]
[+]
SimpleTest
[-] ConfigSchemaTest.php
[edit]
[-] Harness.php
[edit]
[-] EntityLookupTest.php
[edit]
[-] URISchemeRegistryTest.php
[edit]
[+]
ConfigSchema
[-] URIDefinitionTest.php
[edit]
[-] ErrorCollectorEMock.php
[edit]
[+]
Filter
[-] ErrorsHarness.php
[edit]
[-] HTMLModuleHarness.php
[edit]
[-] InjectorHarness.php
[edit]
[-] AttrTransformHarness.php
[edit]
[-] URIFilterHarness.php
[edit]
[-] LanguageFactoryTest.php
[edit]
[+]
PHPT
[+]
Injector
[-] UnitConverterTest.php
[edit]
[-] TokenTest.php
[edit]
[-] LexerTest.php
[edit]
[-] GeneratorTest.php
[edit]
[-] DefinitionTestable.php
[edit]
[-] AttrDefTest.php
[edit]
[-] StringHashParserTest.php
[edit]
[+]
AttrDef
[-] HTMLDefinitionTest.php
[edit]
[-] DefinitionCacheTest.php
[edit]
[+]
HTMLT
[-] ConfigTest-loadIni.ini
[edit]
[+]
VarParser
[-] URISchemeTest.php
[edit]
[-] StrategyHarness.php
[edit]
[+]
ChildDef
[-] AttrDefHarness.php
[edit]
[-] AttrTransformTest.php
[edit]
[-] URIParserTest.php
[edit]
[+]
DefinitionCache
[-] DefinitionTest.php
[edit]
[-] TokenFactoryTest.php
[edit]
[-] ElementDefTest.php
[edit]
[-] DefinitionCacheFactoryTest.php
[edit]
[-] StringHashTest.php
[edit]
[-] ContextTest.php
[edit]
[-] URITest.php
[edit]
[-] ConfigTest.php
[edit]
[-] AttrValidator_ErrorsTest.php
[edit]
[-] URIHarness.php
[edit]
[+]
StringHashParser
[+]
HTMLModule
[-] LanguageTest.php
[edit]
[+]
Strategy
[-] DoctypeRegistryTest.php
[edit]
[-] AttrTypesTest.php
[edit]
[-] PercentEncoderTest.php
[edit]
[-] TagTransformTest.php
[edit]
[-] EncoderTest.php
[edit]
[+]
URIFilter
[-] PropertyListTest.php
[edit]
[-] ConfigTest-create.ini
[edit]
[-] ErrorCollectorTest.php
[edit]
[-] ConfigTest-finalize.ini
[edit]
[+]
Lexer
[-] ComplexHarness.php
[edit]
[-] DefinitionCacheHarness.php
[edit]
[-] AttrCollectionsTest.php
[edit]