메소드 |
설명 |
|
__callStatic ( string $name, array $arguments ) : [type] |
We use this magic method to map various assertion calls to assert_{$name}()
This is so we can break out the call to add_assertion_result() and test
the assertion methods properly |
|
after ( Closure $after ) |
register a function to run after the current suite's tests |
|
assert_all_ok ( array | Traversable $a, callable $callback, string $msg = null ) |
Iterate over all the items in $a and pass each to $callback. If the
callback returns true for all, it passes -- otherwise it fails |
|
assert_equal ( mixed $a, mixed $b, string $msg = null ) |
assert that $a is equal to $b. Uses == for comparison |
|
assert_expect_fail ( string $msg = null ) |
Fail an assertion in an expected way |
|
assert_fail ( string $msg = null, $expected = false ) |
Force a failed assertion |
|
assert_has ( string $needle, array | object $haystack, string $msg = null ) |
assert that $haystack has a key or property named $needle. If $haystack
is neither, returns false |
|
assert_not_equal ( mixed $a, mixed $b, string $msg = null ) |
assert that $a is not equal to $b. Uses != for comparison |
|
assert_not_has ( string $needle, array | object $haystack, string $msg = null ) |
assert that $haystack does not have a key or property named $needle. If $haystack
is neither an array or object, returns false |
|
assert_not_ok ( mixed $a, string $msg = null ) |
assert that $a is falsy. Casts $a to boolean for result |
|
assert_not_strict_equal ( mixed $a, mixed $b, string $msg = null ) |
assert that $a is strictly not equal to $b. Uses !== for comparison |
|
assert_ok ( mixed $a, string $msg = null ) |
assert that $a is truthy. Casts $a to boolean for result |
|
assert_pass ( string $msg = null ) |
Force a successful assertion |
|
assert_strict_equal ( mixed $a, mixed $b, string $msg = null ) |
assert that $a is strictly equal to $b. Uses === for comparison |
|
assert_throws ( callable $callback, array $params, string $exception = null, string $msg = null ) : boolean |
assert that $callback throws an exception of type $exception |
|
assertion_stats ( array $tests, string $test_name = null ) : array |
Retrieves stats about assertions run. returns an array with the keys 'total', 'pass', 'fail', 'expected_fail' |
|
before ( Closure $before ) |
register a function to run before the current suite's tests |
|
debug_out ( $str ) |
|
|
error_handler ( $num, $msg, $file, $line, $vars ) |
custom error handler to catch errors triggered while running tests. this is
registered at the start of FUnit::run() and deregistered at stop |
|
exception_handler ( Exception $e ) : array |
custom exception handler, massaging the format into the same we use for Errors |
|
exit_code ( ) : integer |
Retrieve the exit code. It scans all suites for their exit codes, and if
AND of them are 1, returns 1. Else 0. |
|
fixture ( string $key, mixed $val = null ) : mixed |
helper to deal with scoping fixtures. To store a fixture:
FUnit::fixture('foo', 'bar');
to retrieve a fixture:
FUnit::fixture('foo'); |
|
get_current_suite ( ) : FUnit\TestSuite | null |
get the current suite. If none current, return null |
|
get_suite ( string $name ) : FUnit\TestSuite |
get an FUnit\TestSuite by name |
|
info_out ( $str ) |
|
|
parse_backtrace ( array $bt_raw ) : array |
this generates an array of formatted strings to represent the backtrace |
|
report ( string $format = 'text', array $tests_data = [] ) |
Output a report |
|
report_all_tests ( string $format ) |
output a report for all tests than have been run from all suites |
|
report_out ( $str ) |
|
|
reset_fixtures ( ) |
removes all fixtures. This won't magically close connections or files, tho |
|
run ( boolean $report = true, string $filter = null, $report_format = null ) |
Run the registered tests, and output a report |
|
run_tests ( string $filter = null ) |
Normally you would not call this method directly |
|
set_debug ( boolean $state ) |
if true, debugging info will be output. |
|
set_disable_reporting ( boolean $state ) |
Passing true will disable the reporting output |
|
set_disable_run ( boolean $state ) |
Passing true will disable the FUnit::run() method. This is used by
the test runner utility to avoid calls to run tests within scripts |
|
set_silence ( boolean $state ) |
if $SILENCE is true, only the report will be output -- no progress etc. |
|
setup ( Closure $setup ) |
register a function to run at the start of each test |
|
str_truncate ( $str_val, integer $maxlen ) : string |
truncates a string. If no second param is passed, no change is made |
|
suite ( string $name = self::DEFAULT_SUITE_NAME ) |
initialize a new test suite. adds a suite to \FUnit::$suites and sets
\FUnit::$current_suite_name to the new suite's name |
|
teardown ( Closure $teardown ) |
register a function to run at the end of each test |
|
test ( string $name, Closure $test ) |
add a test to be run |
|
test_stats ( array $tests ) : array |
Retrieves stats about tests run. returns an array with the keys
'total', 'pass', 'run' |
|
val_to_string ( mixed $val, integer $maxlen = 50 ) : string |
converts all known PHP types into a string representation. Generally
would be less verbose with objects and arrays than FUnit::var_export()
because it uses json_encode() |
|
var_export ( mixed $val, integer $maxlen = 50 ) : string |
uses var_export to get string representation of a value. This differs
from the standard var_export by removing newlines and allowing optional
truncation |
|