當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BaseTest::_indent方法代碼示例

本文整理匯總了PHP中BaseTest::_indent方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseTest::_indent方法的具體用法?PHP BaseTest::_indent怎麽用?PHP BaseTest::_indent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BaseTest的用法示例。


在下文中一共展示了BaseTest::_indent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public static function run()
 {
     self::loadClasses();
     $total = 0;
     $failed = 0;
     $errors = 0;
     echo BaseTest::_indent('Starting testing phase:');
     $cwd = getcwd();
     foreach (self::$children as $instance) {
         chdir(static::classFolder($instance));
         $instance->prepare();
         $methods = get_class_methods($instance);
         foreach ($methods as $method) {
             if (!preg_match('/^test[a-zA-Z0-9_]*$/', $method)) {
                 continue;
             }
             static::$state = BaseTest::STATE_OK;
             static::$tests = 0;
             echo BaseTest::_indent('Running test "' . get_class($instance) . '->' . $method . '"<br />', 1);
             try {
                 $msg = call_user_method($method, $instance);
                 if (is_string($msg)) {
                     echo BaseTest::_indent('<span class="message">Got Message ' . $msg . ' </span><br />', 2);
                 }
                 if (static::$state == BaseTest::STATE_OK) {
                     echo BaseTest::_indent('<span class="ok">Sub tests passed (' . static::$tests . ' tests ran)</span><br />', 1);
                 } else {
                     $failed += static::$tests;
                     echo BaseTest::_indent('<span class="warning">Sub tests not passed. (' . static::$tests . ' tests ran)</span><br />', 1);
                 }
                 $total += static::$tests;
             } catch (Exception $e) {
                 static::$tests++;
                 // Was not increased due to error
                 $total += static::$tests;
                 $errors += static::$tests;
                 echo BaseTest::_indent('<span class="error">Error while testing. Msg:' . $e->getMessage() . ' (' . static::$tests . ' tests ran)</span><br />', 1);
                 continue;
             }
             echo '<br />';
         }
         $instance->finish();
     }
     chdir($cwd);
     echo '<div class="results">';
     echo 'Testing finished, a total of <strong>' . $total . '</strong> tests ran: <br />';
     echo BaseTest::_indent('<span class="label label-result">Errors:</span><span class="error">' . $errors . '</span><br />', 1);
     echo BaseTest::_indent('<span class="label label-result">Fails:</span><span class="warning">' . $failed . '</span><br />', 1);
     echo BaseTest::_indent('<span class="label label-result">Passed:</span><span class="ok">' . ($total - $errors - $failed) . '</span><br />', 1);
     echo '</div>';
 }
開發者ID:Makae,項目名稱:ch.bfh.bti7054.w2014.q.groot,代碼行數:51,代碼來源:class.basetest.php


注:本文中的BaseTest::_indent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。