/** * Asserts that the tokenizer is used as default * * @return void */ public function testAutoloaderUsesTokenizer() { $this->assertTrue(AutoloaderFileParser_Tokenizer::isSupported()); $autoloader = new Autoloader(); $autoloader->register(); $autoloader->remove(); $this->assertTrue($autoloader->getParser() instanceof AutoloaderFileParser_Tokenizer); }
function testPsr4LeadingAndTrailingNsSepTrailingDirSep() { $loader = new Autoloader(); $loader->addPsr4('\\Baz\\Bar\\', './data/Baz/src/'); $foo = new \Baz\Bar\Buzz\Foo(); $this->assertInstanceOf('Baz\\Bar\\Buzz\\Foo', $foo); $loader->remove('\\Baz\\Bar\\', './data/Baz/src/'); }
/** * Asserts that Autoloader::getRegisteredAutoloaders() returns all registered * instances of Autoloaders * * @see Autoloader::getRegisteredAutoloaders() * @return void */ public function testGetRegisteredAutoloaders() { $autoloaders = array(); $autoloaders[] = Autoloader::getRegisteredAutoloader(); $newAutoloader = new Autoloader(sys_get_temp_dir()); $newAutoloader->register(); $autoloaders[] = $newAutoloader; foreach ($autoloaders as $expectedAutoloader) { foreach (Autoloader::getRegisteredAutoloaders() as $autoloader) { if ($autoloader === $expectedAutoloader) { continue 2; } } $this->fail("Autoloader wasn't registered."); } $newAutoloader->remove(); }