mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-14 01:31:52 +00:00
c0dd6944a3
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1609 48356398-32a2-884e-a903-53898d9a118a
32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
class HTMLPurifier_ConfigSchema_Validator_IfTest extends HTMLPurifier_ConfigSchema_ValidatorHarness
|
|
{
|
|
|
|
public function setup() {
|
|
parent::setup();
|
|
generate_mock_once('HTMLPurifier_ConfigSchema_Validator');
|
|
}
|
|
|
|
public function testValidate() {
|
|
$arr = array('ID' => 'RD');
|
|
$this->validator->setCondition(new HTMLPurifier_ConfigSchema_Validator_Exists('ID'));
|
|
$this->validator->setThen($mock1 = new HTMLPurifier_ConfigSchema_ValidatorMock());
|
|
$mock1->expectOnce('validate', array($arr, $this->interchange));
|
|
$this->validator->setElse($mock2 = new HTMLPurifier_ConfigSchema_ValidatorMock());
|
|
$mock2->expectNever('validate');
|
|
$this->validator->validate($arr, $this->interchange);
|
|
}
|
|
|
|
public function testValidateConditionIsFalse() {
|
|
$arr = array('ID' => 'RD');
|
|
$this->validator->setCondition(new HTMLPurifier_ConfigSchema_Validator_Exists('ALTID'));
|
|
$this->validator->setThen($mock1 = new HTMLPurifier_ConfigSchema_ValidatorMock());
|
|
$mock1->expectNever('validate');
|
|
$this->validator->setElse($mock2 = new HTMLPurifier_ConfigSchema_ValidatorMock());
|
|
$mock2->expectOnce('validate', array($arr, $this->interchange));
|
|
$this->validator->validate($arr, $this->interchange);
|
|
}
|
|
|
|
}
|