/** * Tests normalization * * An autoloader will unregister itself automatically if another autoloader * would include it. On the other hand, if including autoloader is unregistered * all automatically unregistered autoloaders should be registered again. * * @see Autoloader::register() * @see Autoloader::remove() * @see Autoloader::_normalizeSearchPaths() * @see Autoloader::_removeByNormalization() * @return void */ public function testNormalizedClassPaths() { $autoloader = Autoloader::getRegisteredAutoloader(); Autoloader::removeAll(); $classA = $this->_autoloaderTestHelper->makeClass("A", "testNormalizedClassPaths"); $classB = $this->_autoloaderTestHelper->makeClass("B", "testNormalizedClassPaths/B"); $autoloaderA = new Autoloader(AutoloaderTestHelper::getClassDirectory() . "/testNormalizedClassPaths"); $autoloaderA->register(); $autoloaderB = new Autoloader(AutoloaderTestHelper::getClassDirectory() . "/testNormalizedClassPaths/B"); $autoloaderB->register(); $this->assertTrue($autoloaderA->isRegistered()); $this->assertFalse($autoloaderB->isRegistered()); $this->_autoloaderTestHelper->assertLoadable($classA); $this->_autoloaderTestHelper->assertLoadable($classB); Autoloader::removeAll(); $classA = $this->_autoloaderTestHelper->makeClass("A", "testNormalizedClassPaths"); $classB = $this->_autoloaderTestHelper->makeClass("B", "testNormalizedClassPaths/B"); $autoloaderB = new Autoloader(AutoloaderTestHelper::getClassDirectory() . "/testNormalizedClassPaths/B"); $autoloaderB->register(); $autoloaderA = new Autoloader(AutoloaderTestHelper::getClassDirectory() . "/testNormalizedClassPaths"); $autoloaderA->register(); $this->_autoloaderTestHelper->assertLoadable($classA); $this->_autoloaderTestHelper->assertLoadable($classB); $this->assertTrue($autoloaderA->isRegistered()); $this->assertFalse($autoloaderB->isRegistered()); Autoloader::removeAll(); $autoloader->register(); }
/** * Tests two separate classpaths where one is the prefix of the other. * * Registering e.g. classes/ and classes2/ should result in two * registered autoloaders. * * @dataProvider provideTestNormalizedClassPathPrefixRegression() */ public function testNormalizedClassPathPrefixRegression($path1, $path2) { $autoloader = Autoloader::getRegisteredAutoloader(); Autoloader::removeAll(); $classA = $this->_autoloaderTestHelper->makeClass("A", "testNormalizedClassPathPrefixRegression/{$path1}"); $autoloaderA = new Autoloader(AutoloaderTestHelper::getClassDirectory() . "/testNormalizedClassPathPrefixRegression/{$path1}"); $classB = $this->_autoloaderTestHelper->makeClass("B", "testNormalizedClassPathPrefixRegression/{$path2}"); $autoloaderB = new Autoloader(AutoloaderTestHelper::getClassDirectory() . "/testNormalizedClassPathPrefixRegression/{$path2}"); $autoloaderA->register(); $autoloaderB->register(); $this->assertTrue($autoloaderA->isRegistered()); $this->assertTrue($autoloaderB->isRegistered()); Autoloader::removeAll(); $autoloader->register(); }