Example #1
0
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('Midgard MVC Core');
     $tests = midgardmvc_core_tests_helpers::get_tests(__FILE__, __CLASS__, array('dispatch_routes.php'));
     foreach ($tests as $test) {
         $suite->addTestSuite($test);
     }
     return $suite;
 }
Example #2
0
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('MidCOM org_maemo_userdata');
     $tests = midgardmvc_core_tests_helpers::get_tests(__FILE__, __CLASS__);
     foreach ($tests as $test) {
         $suite->addTestSuite($test);
     }
     return $suite;
 }
Example #3
0
 public static function get_tests($directory, $root_class, $add_skip = null)
 {
     $tests = array();
     $skip = array('all.php');
     if (is_array($add_skip)) {
         $skip = array_merge($skip, $add_skip);
     }
     $skip = array_flip($skip);
     if (!is_dir($directory)) {
         $path_parts = pathinfo($directory);
         $directory = $path_parts['dirname'];
     }
     $tests_dir = dir($directory);
     if (!$tests_dir) {
         return $tests;
     }
     $prefix = str_replace('_all', '', $root_class);
     while (($testfile = $tests_dir->read()) !== false) {
         if (array_key_exists($testfile, $skip) || substr($testfile, 0, 1) == '.') {
             continue;
         }
         $filepath = realpath($directory) . "/{$testfile}";
         if (is_dir($filepath)) {
             $tests = array_merge($tests, midgardmvc_core_tests_helpers::get_tests($filepath, "{$prefix}_{$testfile}"));
             continue;
         }
         $path_parts = pathinfo($filepath);
         if ($path_parts['extension'] != 'php') {
             continue;
         }
         require_once $filepath;
         $test_class = "{$prefix}_{$path_parts['filename']}";
         $tests[] = $test_class;
     }
     $tests_dir->close();
     return $tests;
 }