1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 03:10:09 +02:00

[3.1.0] Create decorator validator/adapter for Interchange.

- Output flush output

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1587 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-02 04:00:43 +00:00
parent d81bcbd208
commit 0d9c05d13c
7 changed files with 99 additions and 24 deletions

View File

@@ -14,7 +14,7 @@ class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase
'ID' => 'Namespace',
'DESCRIPTION' => 'Bar',
));
$this->assertIdentical($v, $this->interchange->getNamespace('Namespace'));
$this->assertIdentical($v, $this->interchange->namespaces['Namespace']);
}
public function testAddDirective() {
@@ -22,7 +22,13 @@ class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase
'ID' => 'Namespace.Directive',
'DESCRIPTION' => 'Bar',
));
$this->assertIdentical($v, $this->interchange->getDirective('Namespace.Directive'));
$this->assertIdentical($v, $this->interchange->directives['Namespace.Directive']);
}
public function testValidator() {
$adapter = $this->interchange->getValidatorAdapter();
$this->expectException(new HTMLPurifier_ConfigSchema_Exception('ID must exist in directive'));
$adapter->addDirective(array());
}
}

View File

@@ -0,0 +1,33 @@
<?php
class HTMLPurifier_ConfigSchema_InterchangeValidatorTest extends UnitTestCase
{
public function setup() {
generate_mock_once('HTMLPurifier_ConfigSchema_Interchange');
$this->mock = new HTMLPurifier_ConfigSchema_InterchangeMock();
$this->validator = new HTMLPurifier_ConfigSchema_InterchangeValidator($this->mock);
}
protected function makeValidator($expect_method, $expect_params) {
generate_mock_once('HTMLPurifier_ConfigSchema_Validator');
$validator = new HTMLPurifier_ConfigSchema_ValidatorMock();
$validator->expectOnce($expect_method, $expect_params);
return $validator;
}
public function testAddNamespaceNullValidator() {
$hash = array('ID' => 'Namespace');
$this->mock->expectOnce('addNamespace', array($hash));
$this->validator->addNamespace($hash);
}
public function testAddNamespaceWithValidators() {
$hash = array('ID' => 'Namespace');
$this->validator->addValidator($this->makeValidator('validateNamespace', array($hash, $this->mock)));
$this->validator->addValidator($this->makeValidator('validateNamespace', array($hash, $this->mock)));
$this->mock->expectOnce('addNamespace', array($hash));
$this->validator->addNamespace($hash);
}
}

View File

@@ -71,7 +71,11 @@ require 'HTMLPurifier/Harness.php';
// Shell-script code is executed
if ($AC['flush']) {
shell_exec($AC['php'] . ' ../maintenance/flush.php');
if (SimpleReporter::inCli() && !$AC['xml']) {
passthru($AC['php'] . ' ../maintenance/flush.php');
} else {
shell_exec($AC['php'] . ' ../maintenance/flush.php');
}
}
// Now, userland code begins to be executed