mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-15 01:28:42 +00:00
d8cb360f3b
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1589 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->addNamespaceValidator($this->makeValidator(array($hash, $this->mock)));
|
|
$this->validator->addDirectiveValidator($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->addNamespaceValidator($this->makeValidator()); // not called
|
|
$this->validator->addDirectiveValidator($this->makeValidator(array($hash, $this->mock)));
|
|
$this->mock->expectOnce('addDirective', array($hash));
|
|
$this->validator->addDirective($hash);
|
|
}
|
|
|
|
}
|