当前位置: 首页>>代码示例>>PHP>>正文


PHP TestSuite::Run方法代码示例

本文整理汇总了PHP中TestSuite::Run方法的典型用法代码示例。如果您正苦于以下问题:PHP TestSuite::Run方法的具体用法?PHP TestSuite::Run怎么用?PHP TestSuite::Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestSuite的用法示例。


在下文中一共展示了TestSuite::Run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: TestSuite

$test_path = "{$CONFIG->path}/engine/tests";
require_once "{$vendor_path}/unit_tester.php";
require_once "{$vendor_path}/mock_objects.php";
require_once "{$vendor_path}/reporter.php";
require_once "{$test_path}/elgg_unit_test.php";
// turn off system log
elgg_unregister_event_handler('all', 'all', 'system_log_listener');
elgg_unregister_event_handler('log', 'systemlog', 'system_log_default_logger');
// Disable maximum execution time.
// Tests take a while...
set_time_limit(0);
$suite = new TestSuite('Elgg Core Unit Tests');
// emit a hook to pull in all tests
$test_files = elgg_trigger_plugin_hook('unit_test', 'system', null, array());
foreach ($test_files as $file) {
    $suite->addTestFile($file);
}
// Only run tests in debug mode.
if (!isset($CONFIG->debug)) {
    exit('The site must be in debug mode to run unit tests.');
}
if (TextReporter::inCli()) {
    // In CLI error codes are returned: 0 is success
    elgg_set_ignore_access(TRUE);
    exit($suite->Run(new TextReporter()) ? 0 : 1);
}
// Ensure that only logged-in users can see this page
//admin_gatekeeper();
$old = elgg_set_ignore_access(TRUE);
$suite->Run(new HtmlReporter('utf-8'));
elgg_set_ignore_access($old);
开发者ID:duanhv,项目名称:mdg-social,代码行数:31,代码来源:suite.php

示例2: foreach

    foreach ($subtypes as $subtype => $actions) {
        $notifications->unregisterEvent($type, $subtype);
    }
}
// disable emails
_elgg_services()->setValue('mailer', new InMemoryTransport());
// Disable maximum execution time.
// Tests take a while...
set_time_limit(0);
$suite = new TestSuite('Elgg Core Unit Tests');
// emit a hook to pull in all tests
$test_files = elgg_trigger_plugin_hook('unit_test', 'system', null, array());
foreach ($test_files as $file) {
    $suite->addFile($file);
}
if (TextReporter::inCli()) {
    // In CLI error codes are returned: 0 is success
    $start_time = microtime(true);
    $reporter = new TextReporter();
    $result = $suite->Run($reporter) ? 0 : 1;
    echo sprintf("Time: %.2f seconds, Memory: %.2fMb\n", microtime(true) - $start_time, memory_get_peak_usage() / 1048576.0);
    // deactivate plugins that were activated for test suite
    foreach ($plugins as $key => $id) {
        $plugin = elgg_get_plugin_from_id($id);
        $plugin->deactivate();
    }
    exit($result);
}
$old = elgg_set_ignore_access(true);
$suite->Run(new HtmlReporter('utf-8'));
elgg_set_ignore_access($old);
开发者ID:cyrixhero,项目名称:Elgg,代码行数:31,代码来源:suite.php

示例3: Run

 protected function Run(TestSuite &$suite, $filename, $extension)
 {
     $suite->Run($this);
     $report = $this->Report();
     if ('string' != gettype($filename)) {
         echo $report;
     } else {
         if ('' == $filename) {
             $filename = tempnam(sys_get_temp_dir(), 'rep');
         }
         $filename .= '.' . $extension;
         $fh = fopen($filename, 'w');
         if (!$fh) {
             echo 'Unable to open file to write to: ' . $filename . "\n";
             return -2;
         }
         echo 'Writing results to: ' . $filename . "\n";
         if (!fwrite($fh, $report)) {
             echo 'Unable to write to file: ' . $filename . "\n";
             return -3;
         }
         fclose($fh);
     }
     return $suite->AllPassed() ? 0 : -1;
 }
开发者ID:hyperpublic,项目名称:hyperpublic_php,代码行数:25,代码来源:php_unit_test.php


注:本文中的TestSuite::Run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。