I'm writing and testing a ClassLoader component, which can be instantiated many times, with various mappings between class names and their relevant paths. Each ClassLoader should work as a loader for a specific package.
Is there an easy, unobtrusive way to test or mock inclusion of files handled by the ClassLoader?
Let me clarify with a simplest possible Loader:
class TestTwoPackageLoader implements IPackageLoader
{
private $directory;
public function register()
{
spl_autoload_register(array($this, 'loadClass'));
$this->directory = dirname(__FILE__);
}
public function loadClass($class)
{
if (isset($this->classes[$class]))
include $this->directory.'/'.$this->classes[$class];
}
private $classes = array(
'SecClass' => 'test_two/SecClass.php',
'ThClass' => 'test_two/ThClass.php',
);
}