コード例 #1
0
 public function testAutoload()
 {
     $this->assertFalse(cfhCompile_Loader::autoload('UNKNOWN_CLASS'));
     $this->assertEquals('cfhCompile_Loader', cfhCompile_Loader::autoload('cfhCompile_Loader'));
     if (!class_exists('cfhCompile_Exception', FALSE)) {
         $this->assertEquals('cfhCompile_Exception', cfhCompile_Loader::autoload('cfhCompile_Exception'));
     } else {
         $this->markTestIncomplete('cfhCompile_Exception class has already been loaded.');
     }
 }
コード例 #2
0
 /**
  * Loads a class from a PHP file.  The filename must be formatted
  * as "$class.php".
  *
  * @param string $class
  * @return void
  * @throws RuntimeException
  */
 public static function loadClass($class)
 {
     if (class_exists($class, false) || interface_exists($class, false)) {
         return;
     }
     if (!self::$basePath) {
         self::$basePath = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR;
     }
     $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
     $pathName = self::$basePath . $file;
     if (!is_file($pathName)) {
         throw new RuntimeException('Unable to load class "' . $class . '" as file "' . $file . '" does not exist.');
     }
     if (!@is_readable($pathName)) {
         throw new RuntimeException('Unable to load class "' . $class . '" as file "' . $file . '" is not readable.');
     }
     require $pathName;
     if (!class_exists($class, false) && !interface_exists($class, false)) {
         throw new RuntimeException('File "' . $file . '" was loaded but class "' . $class . '" was not found in the file.');
     }
 }
コード例 #3
0
 * @copyright   Copyright (c) 2007 - 2008 William Bailey <*****@*****.**>.
 * @license     http://www.gnu.org/licenses/lgpl.html     Lesser GPL
 * @version     $Id$
 */
error_reporting(E_ALL | E_STRICT);
chdir(dirname(__FILE__));
require_once 'PHPUnit/Util/Filter.php';
require_once 'PHPUnit/Framework/TestSuite.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'PHPUnit/Extensions/Database/TestCase.php';
if (file_exists('cfhCompile.compiled.php')) {
    require_once 'cfhCompile.compiled.php';
    PHPUnit_Util_Filter::addFileToWhitelist('cfhCompile.compiled.php');
} else {
    require_once '../library/cfhCompile/Loader.php';
    cfhCompile_Loader::registerAutoload();
    PHPUnit_Util_Filter::addDirectoryToWhitelist(realpath('../library/'));
    PHPUnit_Util_Filter::addFileToFilter(__FILE__);
}
/**
 * Main Unit Test Class.
 *
 * @category    cfh
 * @package     cfhCompile
 * @subpackage  UnitTests
 * @copyright   Copyright (c) 2007 - 2008 William Bailey <*****@*****.**>.
 */
class AllTests
{
    public static function suite($dir = NULL)
    {