2006-08-06 01:03:48 +00:00
|
|
|
<?php
|
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
class HTMLPurifier_AttrDef_HTML_PixelsTest extends HTMLPurifier_AttrDefHarness
|
2006-08-06 01:03:48 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setup()
|
|
|
|
{
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->def = new HTMLPurifier_AttrDef_HTML_Pixels();
|
2006-08-06 01:30:54 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function test()
|
|
|
|
{
|
2006-08-06 01:03:48 +00:00
|
|
|
$this->assertDef('1');
|
|
|
|
$this->assertDef('0');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
$this->assertDef('2px', '2'); // rm px suffix
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
$this->assertDef('dfs', false); // totally invalid value
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
// conceivably we could repair this value, but we won't for now
|
|
|
|
$this->assertDef('9in', false);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
// test trim
|
|
|
|
$this->assertDef(' 45 ', '45');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
// no negatives
|
|
|
|
$this->assertDef('-2', '0');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
// remove empty
|
|
|
|
$this->assertDef('', false);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
// round down
|
|
|
|
$this->assertDef('4.9', '4');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function test_make()
|
|
|
|
{
|
2008-05-23 02:09:43 +00:00
|
|
|
$factory = new HTMLPurifier_AttrDef_HTML_Pixels();
|
|
|
|
$this->def = $factory->make('30');
|
|
|
|
$this->assertDef('25');
|
|
|
|
$this->assertDef('35', '30');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-06 01:03:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|