예제 #1
0
 public static function suite()
 {
     ini_set('display_errors', 1);
     $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
     $mask = realpath(dirname(__FILE__) . '/../modules') . '/*/{tests,class.*.test}.php';
     foreach (glob($mask, GLOB_BRACE) as $file) {
         $module = basename(dirname($file));
         if ('.test.php' == substr(basename($file), -9)) {
             $class = ucfirst(substr(basename($file), 6, -9)) . 'Tests';
         } else {
             $class = ucfirst($module) . 'ModuleTests';
         }
         require_once $file;
         if (class_exists($class, false)) {
             printf("%s => %s\n", os::localPath($file), $class);
             $suite->addTestSuite($class);
         } else {
             die("Class {$class} not found in {$file}.\n");
         }
     }
     ini_set('error_log', dirname(__FILE__) . '/tests.log');
     ini_set('display_errors', 1);
     return $suite;
 }
예제 #2
0
 /**
  * Форматирование элемента стэка.
  */
 public static function formatStackElement(array $em)
 {
     $output = '';
     if (!empty($em['file'])) {
         $output .= os::localPath($em['file']) . '(' . $em['line'] . ') — ';
     }
     $caller = empty($em['class']) ? '' : $em['class'];
     $caller .= empty($em['type']) ? '' : $em['type'];
     if (!empty($em['function'])) {
         $caller .= $em['function'] . '(';
         if (!empty($em['args'])) {
             $args = array();
             foreach ($em['args'] as $arg) {
                 if (is_array($arg)) {
                     $args[] = 'array';
                 } elseif (is_object($arg)) {
                     $args[] = get_class($arg);
                 } elseif (true === $arg) {
                     $args[] = 'true';
                 } elseif (false === $arg) {
                     $args[] = 'false';
                 } elseif (null === $arg) {
                     $args[] = 'null';
                 } elseif (is_string($arg)) {
                     $tmp = '"';
                     $tmp .= mb_strlen($arg) > 10 ? mb_substr($arg, 0, 10) . '...' : $arg;
                     $tmp .= '"';
                     $args[] = $tmp;
                 } else {
                     $args[] = $arg;
                 }
             }
             $caller .= join(', ', $args);
         }
         $caller .= ');';
     }
     $output .= $caller;
     return $output;
 }