1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 13:47:24 +02:00

PSR-2 reformatting PHPDoc corrections

With minor corrections.

Signed-off-by: Marcus Bointon <marcus@synchromedia.co.uk>
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Marcus Bointon
2013-07-16 13:56:14 +02:00
committed by Edward Z. Yang
parent 19eee14899
commit fac747bdbd
433 changed files with 13302 additions and 6690 deletions

View File

@@ -5,11 +5,13 @@ class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase
protected $interchange;
public function setup() {
public function setup()
{
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
}
function testAddDirective() {
public function testAddDirective()
{
$v = new HTMLPurifier_ConfigSchema_Interchange_Directive();
$v->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Namespace.Directive');
$this->interchange->addDirective($v);

View File

@@ -3,87 +3,105 @@
class HTMLPurifier_ConfigSchema_ValidatorAtomTest extends UnitTestCase
{
protected function expectValidationException($msg) {
protected function expectValidationException($msg)
{
$this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
}
protected function makeAtom($value) {
protected function makeAtom($value)
{
$obj = new stdClass();
$obj->property = $value;
// Note that 'property' and 'context' are magic wildcard values
return new HTMLPurifier_ConfigSchema_ValidatorAtom('context', $obj, 'property');
}
function testAssertIsString() {
public function testAssertIsString()
{
$this->makeAtom('foo')->assertIsString();
}
function testAssertIsStringFail() {
public function testAssertIsStringFail()
{
$this->expectValidationException("Property in context must be a string");
$this->makeAtom(3)->assertIsString();
}
function testAssertNotNull() {
public function testAssertNotNull()
{
$this->makeAtom('foo')->assertNotNull();
}
function testAssertNotNullFail() {
public function testAssertNotNullFail()
{
$this->expectValidationException("Property in context must not be null");
$this->makeAtom(null)->assertNotNull();
}
function testAssertAlnum() {
public function testAssertAlnum()
{
$this->makeAtom('foo2')->assertAlnum();
}
function testAssertAlnumFail() {
public function testAssertAlnumFail()
{
$this->expectValidationException("Property in context must be alphanumeric");
$this->makeAtom('%a')->assertAlnum();
}
function testAssertAlnumFailIsString() {
public function testAssertAlnumFailIsString()
{
$this->expectValidationException("Property in context must be a string");
$this->makeAtom(3)->assertAlnum();
}
function testAssertNotEmpty() {
public function testAssertNotEmpty()
{
$this->makeAtom('foo')->assertNotEmpty();
}
function testAssertNotEmptyFail() {
public function testAssertNotEmptyFail()
{
$this->expectValidationException("Property in context must not be empty");
$this->makeAtom('')->assertNotEmpty();
}
function testAssertIsBool() {
public function testAssertIsBool()
{
$this->makeAtom(false)->assertIsBool();
}
function testAssertIsBoolFail() {
public function testAssertIsBoolFail()
{
$this->expectValidationException("Property in context must be a boolean");
$this->makeAtom('0')->assertIsBool();
}
function testAssertIsArray() {
public function testAssertIsArray()
{
$this->makeAtom(array())->assertIsArray();
}
function testAssertIsArrayFail() {
public function testAssertIsArrayFail()
{
$this->expectValidationException("Property in context must be an array");
$this->makeAtom('asdf')->assertIsArray();
}
function testAssertIsLookup() {
public function testAssertIsLookup()
{
$this->makeAtom(array('foo' => true))->assertIsLookup();
}
function testAssertIsLookupFail() {
public function testAssertIsLookupFail()
{
$this->expectValidationException("Property in context must be a lookup array");
$this->makeAtom(array('foo' => 4))->assertIsLookup();
}
function testAssertIsLookupFailIsArray() {
public function testAssertIsLookupFailIsArray()
{
$this->expectValidationException("Property in context must be an array");
$this->makeAtom('asdf')->assertIsLookup();
}

View File

@@ -8,19 +8,22 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
{
public $validator, $interchange;
public function setup() {
public function setup()
{
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
}
function testDirectiveIntegrityViolation() {
public function testDirectiveIntegrityViolation()
{
$d = $this->makeDirective('Ns.Dir');
$d->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Ns.Dir2');
$this->expectValidationException("Integrity violation: key 'Ns.Dir' does not match internal id 'Ns.Dir2'");
$this->validator->validate($this->interchange);
}
function testDirectiveTypeNotEmpty() {
public function testDirectiveTypeNotEmpty()
{
$d = $this->makeDirective('Ns.Dir');
$d->default = 0;
$d->description = 'Description';
@@ -29,7 +32,8 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$this->validator->validate($this->interchange);
}
function testDirectiveDefaultInvalid() {
public function testDirectiveDefaultInvalid()
{
$d = $this->makeDirective('Ns.Dir');
$d->default = 'asdf';
$d->type = 'int';
@@ -39,7 +43,8 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$this->validator->validate($this->interchange);
}
function testDirectiveIdIsString() {
public function testDirectiveIdIsString()
{
$d = $this->makeDirective(3);
$d->default = 0;
$d->type = 'int';
@@ -49,7 +54,8 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$this->validator->validate($this->interchange);
}
function testDirectiveTypeAllowsNullIsBool() {
public function testDirectiveTypeAllowsNullIsBool()
{
$d = $this->makeDirective('Ns.Dir');
$d->default = 0;
$d->type = 'int';
@@ -60,7 +66,8 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$this->validator->validate($this->interchange);
}
function testDirectiveValueAliasesIsArray() {
public function testDirectiveValueAliasesIsArray()
{
$d = $this->makeDirective('Ns.Dir');
$d->default = 'a';
$d->type = 'string';
@@ -71,7 +78,8 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$this->validator->validate($this->interchange);
}
function testDirectiveAllowedIsLookup() {
public function testDirectiveAllowedIsLookup()
{
$d = $this->makeDirective('Ns.Dir');
$d->default = 'foo';
$d->type = 'string';
@@ -85,14 +93,16 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
// helper functions
protected function makeDirective($key) {
protected function makeDirective($key)
{
$directive = new HTMLPurifier_ConfigSchema_Interchange_Directive();
$directive->id = new HTMLPurifier_ConfigSchema_Interchange_Id($key);
$this->interchange->addDirective($directive);
return $directive;
}
protected function expectValidationException($msg) {
protected function expectValidationException($msg)
{
$this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
}

View File

@@ -9,18 +9,21 @@ class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
protected $_path, $_parser, $_builder;
public $validator;
public function __construct($path) {
public function __construct($path)
{
$this->_path = $path;
$this->_parser = new HTMLPurifier_StringHashParser();
$this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
parent::__construct($path);
}
public function setup() {
public function setup()
{
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
}
function testValidator() {
public function testValidator()
{
$hashes = $this->_parser->parseMultiFile($this->_path);
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
$error = null;