Example #1
0
 public function __construct($run_from_commandline = false)
 {
     if ($run_from_commandline) {
         $this->init_constants();
         echo "Bootstrapping Testing System by Testing Autoloader...\n";
         $bootstrap_test = $this->bootstrap_test_autoloader();
         if ($bootstrap_test->tests_failed) {
             echo "Bootstrap Fail, stopping subsequent tests.\n";
             echo "=== DEBUG ===\n";
             echo $bootstrap_test->output;
             exit;
         } else {
             echo "Bootstrap Pass, continuing...\n";
         }
         echo "Running TethAutoloader::init()\n";
         TethAutoloader::init();
         echo "Running TethAutoloader::register_classes()\n";
         TethAutoloader::register_classes(array(SITE_DIR));
         $this->test_classes = $this->scan_classes(TethAutoloader::$classes);
         echo "Found " . count($this->test_classes) . " test classes ...\n";
         $this->run_tests();
     }
 }
Example #2
0
 public function register_classes()
 {
     $ret = true;
     //copy over the current settings
     $original_classes = TethAutoloader::$classes;
     $original_comps = TethAutoloader::$components;
     //wipe them ready for testing
     TethAutoloader::$classes = TethAutoloader::$components = array();
     $dir = array('testing_register_classes' => dirname(__FILE__));
     //register all the test classes directory
     TethAutoloader::register_classes($dir);
     $class = get_class($this);
     $class_path = __FILE__;
     if (!isset(TethAutoloader::$classes[$class])) {
         $this->results['register_classes']['added_to_array'] = $ret = false;
     } else {
         $this->results['register_classes']['added_to_array'] = true;
     }
     //as long as the class path matches then its all ok!
     if (TethAutoloader::$classes[$class] != $class_path) {
         $this->results['register_classes']['correct_path'] = $ret = false;
     } else {
         $this->results['register_classes']['correct_path'] = true;
     }
     //reset these back to originals so not to pollute other tests
     TethAutoloader::$classes = $original_classes;
     TethAutoloader::$components = $original_comps;
     return $ret;
 }