mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-14 01:08:41 +00:00
e4ab6d584e
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1606 48356398-32a2-884e-a903-53898d9a118a
45 lines
1.9 KiB
PHP
45 lines
1.9 KiB
PHP
<?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_params = null) {
|
|
generate_mock_once('HTMLPurifier_ConfigSchema_Validator');
|
|
$validator = new HTMLPurifier_ConfigSchema_ValidatorMock();
|
|
if ($expect_params !== null) $validator->expectOnce('validate', $expect_params);
|
|
else $validator->expectNever('validate');
|
|
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(array($hash, $this->mock)));
|
|
$this->validator->namespace->addValidator($this->makeValidator(array($hash, $this->mock)));
|
|
$this->validator->directive->addValidator($this->makeValidator()); // not called
|
|
$this->mock->expectOnce('addNamespace', array($hash));
|
|
$this->validator->addNamespace($hash);
|
|
}
|
|
|
|
public function testAddDirectiveWithValidators() {
|
|
$hash = array('ID' => 'Namespace.Directive');
|
|
$this->validator->addValidator($this->makeValidator(array($hash, $this->mock)));
|
|
$this->validator->namespace->addValidator($this->makeValidator()); // not called
|
|
$this->validator->directive->addValidator($this->makeValidator(array($hash, $this->mock)));
|
|
$this->mock->expectOnce('addDirective', array($hash));
|
|
$this->validator->addDirective($hash);
|
|
}
|
|
|
|
}
|