$value) {
// $fake_registry isn't the real mock, because due to PHP 4 weirdness
// I cannot set a default value to function parameters that are passed
// by reference. So we use the value instance() returns.
$fake_registry = new HTMLPurifier_URISchemeRegistryMock($this);
$registry =& HTMLPurifier_URISchemeRegistry::instance($fake_registry);
// now, let's at a pseudo-scheme to the registry
$scheme =& new HTMLPurifier_URISchemeMock($this);
// here are the schemes we will support with overloaded mocks
$registry->setReturnReference('getScheme', $scheme, array('http'));
$registry->setReturnReference('getScheme', $scheme, array('mailto'));
// default return value is false (meaning no scheme defined: reject)
$registry->setReturnValue('getScheme', false, array('*'));
if (!isset($return_components[$i])) {
$return_components[$i] = $components[$i];
}
if (!isset($expect_uri[$i])) {
$expect_uri[$i] = $value;
}
if (!isset($config[$i])) {
$config[$i] = HTMLPurifier_Config::createDefault();
}
if (!isset($context[$i])) {
$context[$i] = new HTMLPurifier_AttrContext();
}
if ($components[$i] === false) {
$scheme->expectNever('validateComponents');
} else {
$scheme->setReturnValue(
'validateComponents', $return_components[$i], $components[$i]);
$scheme->expectOnce('validateComponents', $components[$i]);
}
$result = $def->validate($value, $config[$i], $context[$i]);
$scheme->tally();
$this->assertIdentical($expect_uri[$i], $result, "Test $i: %s");
}
// reset to regular implementation
HTMLPurifier_URISchemeRegistry::instance($old_registry);
}
}
?>