/**
  * 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);
 }
 /**
  * Removes all Autoloaders from the stack and initializes
  * the AutoloaderTestHelper $_autoloaderTestHelper.
  *
  * @see $_autoloaderTestHelper
  * @return void
  */
 public function setUp()
 {
     $this->_autoloaderTestHelper = new AutoloaderTestHelper($this);
     Autoloader::removeAll();
 }
 /**
  * The test will add manually classes to the index.
  *
  * The test will assert with this method, that a class in the index is not
  * searched by the file system.
  *
  * @param String $class The class name
  * 
  * @return void
  */
 public function addClassToIndex($class)
 {
     $this->normalizeClass($class);
     if ($this->index->hasPath($class)) {
         return;
     }
     $this->index->setPath($class, parent::searchPath($class));
 }
Example #4
0
 /**
  * Asserts that including the file Autoloader.php will register each time an
  * instance of Autoloader with the correct class path
  * 
  * @see Autoloader.php
  * @return void
  */
 public function testSeveralRequiredAutoloaders()
 {
     $autoloaders = Autoloader::getRegisteredAutoloaders();
     Autoloader::removeAll();
     $autoloaderPath = __DIR__ . "/../autoloader.php";
     $classA = $this->_autoloaderTestHelper->makeClass("A", "a");
     $classA2 = $this->_autoloaderTestHelper->makeClass("A2", "a");
     $requireA = $this->_autoloaderTestHelper->makeClass("requireA", "a", "<?php require '{$autoloaderPath}' ?>");
     $classB = $this->_autoloaderTestHelper->makeClass("B", "b");
     $requireB = $this->_autoloaderTestHelper->makeClass("requireB", "b", "<?php require '{$autoloaderPath}' ?>");
     $this->_autoloaderTestHelper->assertNotLoadable($classA);
     $this->_autoloaderTestHelper->assertNotLoadable($classA2);
     include AutoloaderTestHelper::getClassDirectory() . DIRECTORY_SEPARATOR . "a" . DIRECTORY_SEPARATOR . "{$requireA}.test.php";
     $this->_autoloaderTestHelper->assertLoadable($classA);
     $this->_autoloaderTestHelper->assertNotLoadable($classB);
     include AutoloaderTestHelper::getClassDirectory() . DIRECTORY_SEPARATOR . "b" . DIRECTORY_SEPARATOR . "{$requireB}.test.php";
     $this->_autoloaderTestHelper->assertLoadable($classA);
     $this->_autoloaderTestHelper->assertLoadable($classA2);
     $this->_autoloaderTestHelper->assertLoadable($classB);
     Autoloader::removeAll();
     foreach ($autoloaders as $autoloader) {
         $autoloader->register();
     }
 }