public static function addAutoloadFile($fileName) { $classes = (include $fileName); if (is_array($classes)) { self::$classes = array_merge(self::$classes, $classes); } }
public function testAutoloadExpectingTrue() { PhpCssLoader::addAutoloadFile(dirname(__FILE__) . '/TestData/LoaderData.php'); PhpCssLoader::autoload('PhpCssLoaderTestClass'); $this->assertTrue(class_exists('PhpCssLoaderTestClass', FALSE)); }
<?php /** * Load necessary files */ require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '/../../src/PhpCss/Loader.php'; PhpCssLoader::addAutoloadFile(dirname(__FILE__) . '/../../src/PhpCss/Loader/All.php'); spl_autoload_register('PhpCssLoader::autoload'); PHPUnit_Util_Filter::addFileToFilter(__FILE__); abstract class PhpCssTestCase extends PHPUnit_Framework_TestCase { public static function includePhpCssFile($file) { include_once dirname(__FILE__) . '/../../src/PhpCss' . $file; } }
<?php /** * PhpCss Demo: Setup Include */ /* Load PhpCss files */ $PhpCssPath = dirname(__FILE__) . '/../../../src/PhpCss/'; require_once $PhpCssPath . 'Loader.php'; PhpCssLoader::addAutoloadFile($PhpCssPath . '/Loader/Scanner.php'); spl_autoload_register('PhpCssLoader::autoload');