Declaration | class PHPcheck |
Datei | phpcheck.php |
Date/Time modify File | 2023-04-25 10:09:50 |
File-Size | 35 KByte |
MD5 File | fdd35fdffb036b57e4ee8bcb1d5ed142 |
Version | 1.66 (const VERSION = 1.66) |
Date | 2023-04-25 |
Methods and Parameter | Description/Comments |
---|---|
public function __construct() | create a instance of phpcheck |
public function __destruct() | |
public function start($comment='') | the method marks the start of new test param $comment set a title/comment of following test |
public function startOutput($comment='') | the method marks the start of new test with Output param $comment set a title/comment of following test works how start() and expectOutput() |
public function check($actual,$testResult,$comment='') | use this method's to finish a test param $actual the result of test param $testResult true/false for test was ok or not param $comment set a title/comment, if method start use this comment will be overwerite return array results |
public function checkEqual($actual,$expected,$comment='', $delta = null) | finish a test param $actual the actual result param $expected the expected result param $comment new comment param $delta if not 0, then check abs($expected-$actual) <= $delta string 'Pn' with n=1..15 for precision n numbers null default-precision return array results |
public function checkNotEqual($actual,$comp,$comment='', $delta = null) | finish a test param $actual the actual result param $comp the comparison param $comment new comment param $delta if not null, then check abs($comp-$actual) <= $delta return array results |
public function checkEqualHex($actual,$expected,$comment='') | finish a test param $actual the actual result, if is string it will be show as hex-string param $expected the expected result param $comment new comment return array results |
public function checkHTML($actual = null, $containStrings = "", $ignoreLibXmlErrors = false) | finish a test param $actual the actual result html-Code param $containStrings: if not "" the result must contain Strings param $ignoreLibXmlErrors: ignor Errors how unknown Tags return array results |
public function checkContains($actual, $containStrings = "") | finish a test param $actual the actual result param $containStrings: if not "" the result must contain Strings return array results |
public function checkOutput($containStrings = "", $outputFilter = null) | finish a test after startOutput param $containStrings : check if output contains the list of strings, default "" param $outputFilter : if not null setResultFilter temp to $outputFilter, p.E. 'html' return array results |
public function checkMultiple($userFct,array $data) | make a multiple test par $userFct: function-name, closure, static method "class::method" or array($class,'method') par $data: multiple array with comment as key and array(par,par2,..,expectedValue) return array results |
public function checkException($closure,$exceptionTyp = "",$comment='') | use this method's to finish a test param $closure a function with testobject param $exceptionTyp the exception or "" for all param $comment set a title/comment, if method start use this comment will be overwerite return array results |
public function expectOutput() | prepare the output buffer for expect a output to check a output you must use expectOutput or startOutput |
public function getOutput() | stop the output buffering and get the output |
public function time() | return float: seconds from last test start |
public function getResults() | return a array of resultarrays from all collected checks array ( 0 => array ( 'line' => 3, //Line number source 'comm' => "1.test", //Comment 'taskCode' => '$result = 3 * 4;', //source code ckeck 'result' => 12, //result that will be checked 'filterResult' => "12", //result after filter 'test' => true, //result of check 'warning' => //Errors and warnings that occur during the test array ( ), 'mctime' => 6.9E-6, //Time required by the test )) |
public function getLastResult($key = null) | return last result or result with the specified key param key string 'line', 'comm', 'mctime' return false if error |
public function getLastPHPcode() | return the PHP Code (taskCode) as highlightPhpString from the last check |
public function getErrorCount() | returns the number of failed tests |
public function getCheckCount() | return count of check-calls |
public function clearChecks() | Delete collected results from all checks |
public function setErrorLevel($level) | set new error level and push old level return old level use this to show warnings and errors only in results and not in top of site |
public function restoreErrorLevel() | restore error level return: current level |
public function setTabSpacePHPview($tabSpace = 4) | set Tabspace for view PHP-Code |
public function setStartWithCheck($enable = true) | true (default): check is automatically start for new test false : start must be called |
public function setResultFilter($filterName = 'default') | set a new result filter for getTable results are filtered with "var_export" (default) If you want present text or html without filter, call setResultFilter with parameter empty string $filtername = 'html' : present strings without filter, other with "var_export" return $oldFilter (>V1.42) |
public function setHeadline($text) | set text for additional Headline |
public function setOutputVariant($variant) | set variant for output Valid variant: "" , "form" "form" creates a button, that allow form-elements send with POST |
public function setOutputOnlyErrors($trueOrFalse) | set variant for output print Only Errors |
public function getPostCount() | get count (cycle number) for POST-cykles return 0 after first Start |
public function getTable($tableAttribut = "", $clearResults = true) | create a full table with results return: html-string param: tableAttribut e.g. 'style=""' param: set $clearResults = false if you may not delete collected results |
public function getHtmlHeader($title = 'Test') | return default html header for a site as string |
public function addCSS($css = "") | add CSS to header |
public function getHtmlFooter() | return default html footer as string |
public static function getOS() | get OS how Linux, Win |
public static function getCpu() | get CPU Name (Machine type) |
public function getTotalInfo() | get total Info (Number of checks, errors..) as HTML |
public function getHtml($withFooter = true) | provides a complete tabular analysis as a web page typical use $t = new phpcheck(); $t->start("first test"); $result = 5 + 4; //our first test $t->checkEqual($result,9); //end first test echo $t->getHTML(); //show analysis |
public function getRandomString($length = 10) | return a random ASCII-String param $length (default 10 chars) |
public function highlightPhpString($phpCode) | Syntax highlighting of a string with php-Code |
public static function getValidateHtmlError($html, $ignoreLibXmlErrors = false) | validate a html-string and get the error notice return "" if ok and not error found return error-message if errror param: HTML as string param: flag $ignoreLibXmlErrors true/false default false |
public function getClassVersion($class=NULL) | @return string version of class return false if error, "" Versioninfo not found @param class: object, string (optional) |
public function getNumberOfLines($fullFileName) | @return number of lines return false if error @param string filename |
public function roundPrecision($floatValue, $overallPrecision = self::DEFAULT_FLOAT_PRECISION) | @return Float-Value with reduced precision @param $floatValue: input (float) @param $overallPrecision: 1..20 (default 14) |
public function isEqual($actual, $expected, $delta = null) | @param $actual mixed test result @param $expected mixed expected result @param $delta mixed $delta>=0 work as eps for float-values, 'Pn' with n=1..15 for precision n numbers or null default-precision @return true/false,null if can not compare |
public function isNegativFloat($value) | return true if value is a float and negative also differentiates between -0.0 and +0.0 @param mixed $value @return true or false |
public function echoImg($gdResource) | echo gd-rsource or gd-object |
public function simulateFile($content) | Simulates a file with a given content. Returns a filename. The file name can be used for file_get_contents() etc. No file is physically created. @param string $content @return string fileName file_exists($simulateFile) return false; |
public function tmpFile($content = " ") | Create a temporary file with a given content. Returns a filename. The file name can be used for file_get_contents() etc. @param string $content @return string fileName |
public function deleteTmpFile() | |
public function _internalErrorHandler($errcode, $errmsg, $fileName, $line) | the internal error handler, do not use |
public static function shutDownHandle($objPhpcheck = null) | internal :not use this method |
Property and Defaults | Description/Comments |
---|---|
public static $instance; |
Declaration/Name | Value | Description/Comments |
---|---|---|
const VERSION = '1.66'; | '1.66' | |
const DISPLAY_PRECISION = 16; | 16 | |
const DEFAULT_FLOAT_PRECISION = 15; | 15 |