/**
  * Asserts that the class $class is loadable after
  * registration of its class definition $path
  *
  * @param String $class The class which is autoloaded
  * @param String $path  The class defintion
  * 
  * @dataProvider provideTestAutoload
  * @return void
  * @see InternalAutoloader::registerClass()
  */
 public function testAutoload($class, $path)
 {
     $autoloaderTestHelper = new AutoloaderTestHelper($this);
     Autoloader::removeAll();
     $autoloaderTestHelper->assertNotLoadable($class);
     InternalAutoloader::getInstance()->registerClass($class, $path);
     $autoloaderTestHelper->assertLoadable($class);
 }
Exemple #2
0
 /**
  * Asserts that registerAutoloader registers callbacks at the stack and
  * can be removed
  *
  * @param AutoloadAPI $api      An AutoloadAPI object
  * @param Mixed       $callback The callback
  *
  * @dataProvider provideCallbacks
  * @return void
  */
 public function testRegisterAndRemove(AutoloadAPI $api, $callback)
 {
     $api->registerAutoloader($callback);
     $this->assertTrue(in_array($callback, $api->getRegisteredAutoloaders()));
     // The autoloader loads now any class
     $class = uniqid('Test');
     $object = new $class();
     $this->assertEquals($class, $object->getName());
     $api->removeAutoloader($callback);
     $this->assertFalse(in_array($callback, $api->getRegisteredAutoloaders()));
     // There is no autoloader left which would load any class
     $class = uniqid('Test2');
     $helper = new AutoloaderTestHelper($this);
     $helper->assertNotLoadable($class);
 }