$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->setReturnValue('getScheme', $scheme, array('http')); $registry->setReturnValue('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 ($components[$i] === false) { $scheme->expectNever('validateComponents'); } else { $scheme->setReturnValue( 'validateComponents', $return_components[$i], $components[$i]); $scheme->expectOnce('validateComponents', $components[$i]); } $result = $def->validate($value); $scheme->tally(); $this->assertIdentical($expect_uri[$i], $result); } // reset to regular implementation HTMLPurifier_URISchemeRegistry::instance($old_registry); } } ?>