コード例 #1
0
 static function throwFromError($code, $message, $file, $line)
 {
     self::$errors_count++;
     self::$error_message = $message . ' in ' . $file . ' on line ' . $line;
     restore_error_handler();
     trigger_error(self::$error_message . "\n", E_USER_ERROR);
 }
コード例 #2
0
<?php

function thisThrowsAnException()
{
    throw new Exception('There was an exception');
}
NaithCliRunner::assertException('thisThrowsAnException');
コード例 #3
0
<?php

xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$base_directory = dirname(__FILE__) . '/../../';
require_once $base_directory . 'NaithCliRunner.class.php';
require_once $base_directory . 'NaithCliReport.class.php';
require_once $base_directory . 'NaithJunitReport.class.php';
$coverage_file_path = dirname(__FILE__) . '/raw_coverage_file.txt';
$tests_report_path = dirname(__FILE__) . '/tests_report_raw.txt';
$junit_xml_path = dirname(__FILE__) . '/junit.xml';
register_shutdown_function('NaithCliRunner::onShutdown');
$junit_report = new NaithJunitReport(array('excluded_paths' => array(dirname(__FILE__) . '/tests/not_fully_tested.php'), 'tests_report_path' => $tests_report_path, 'base_directory' => $base_directory));
$junit_report->writeJunitXmlToFile($junit_xml_path);
echo file_get_contents($junit_xml_path);
NaithCliRunner::setCoverageFilePath($coverage_file_path);
NaithCliRunner::bootstrapForTest();
$report = new NaithCliReport(array('coverage_file_path' => $coverage_file_path, 'excluded_paths' => array(dirname(__FILE__)), 'minimum_code_coverage' => 0, 'base_directory' => $base_directory));
$report->makeUntestedCodeOverview();
$report->makeCoverageOverview();
$report = new NaithCliReport(array('coverage_file_path' => $coverage_file_path, 'excluded_paths' => array(dirname(__FILE__)), 'minimum_code_coverage' => 120, 'base_directory' => $base_directory));
$report->makeUntestedCodeOverview();
$report->makeCoverageOverview();
コード例 #4
0
<?php

function thisDoesNotThrowAnException()
{
    /*
     * DO not throw one!
     */
}
NaithCliRunner::assertException('thisDoesNotThrowAnException');