expectOnce('validate', $def1_params);
$def1->setReturnValue('validate', $output, $def1_params);
$def2->expectNever('validate');
$this->assertIdentical($output,
$def->validate($input, $config, $context));
$def1->tally();
$def2->tally();
// second test, first def fails, second def works
$def1 =& new HTMLPurifier_AttrDefMock($this);
$def2 =& new HTMLPurifier_AttrDefMock($this);
$defs = array(&$def1, &$def2);
$def =& new HTMLPurifier_AttrDef_Composite($defs);
$input = 'BOOMA';
$output = 'booma';
$def_params = array($input, $config, $context);
$def1->expectOnce('validate', $def_params);
$def1->setReturnValue('validate', false, $def_params);
$def2->expectOnce('validate', $def_params);
$def2->setReturnValue('validate', $output, $def_params);
$this->assertIdentical($output,
$def->validate($input, $config, $context));
$def1->tally();
$def2->tally();
// third test, all fail, so composite faiils
$def1 =& new HTMLPurifier_AttrDefMock($this);
$def2 =& new HTMLPurifier_AttrDefMock($this);
$defs = array(&$def1, &$def2);
$def =& new HTMLPurifier_AttrDef_Composite($defs);
$input = 'BOOMA';
$output = false;
$def_params = array($input, $config, $context);
$def1->expectOnce('validate', $def_params);
$def1->setReturnValue('validate', false, $def_params);
$def2->expectOnce('validate', $def_params);
$def2->setReturnValue('validate', false, $def_params);
$this->assertIdentical($output,
$def->validate($input, $config, $context));
$def1->tally();
$def2->tally();
}
}
?>