PHP Class App\Lib\Test

(c) James Healey For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Show file Open project: jayhealey/webception

Public Methods

Method Description
__construct ( )
checkLogForTestFailure ( string $line ) : boolean Checks if line contains failure regex
checkLogForTestPass ( string $line ) : boolean Check if it contains any text that indiciates that the test has passed.
filterFileName ( string $filename ) : string Filter out content from a title any to improve readability of the test name
filterTitle ( string $title ) : string Turn a "CamelCasedString" into "Camel Cased String".
getFilename ( ) : string Get the file Filename
getHash ( ) : string Get the Test Hash
getLog ( $format = TRUE ) : HTML/Array Return the log as a HTML string.
getState ( ) : boolean Get the Test state based on if the test has run or passed.
getTitle ( ) : string Get the Test title
getType ( ) : string Get the Test type
init ( string $type, object $file ) Initialization of the Test
makeHash ( string $string ) : string Generate a unique hash for the test.
passed ( ) : boolean Return if the test was run and passed
ran ( ) : boolean Return if the test was successfully run.
reset ( ) Reset a Test back to default.
setFailed ( ) Sets passed to false if test fails
setLog ( $lines = [] ) Add a new line entry to the Test log.
setPassed ( ) : boolean Set if the test has been passed.

Private Methods

Method Description
filterLog ( String $line ) Filter out junk content from a log line.

Method Details

__construct() public method

public __construct ( )

checkLogForTestFailure() public method

Checks if line contains failure regex
public checkLogForTestFailure ( string $line ) : boolean
$line string
return boolean

checkLogForTestPass() public method

Check if it contains any text that indiciates that the test has passed.
public checkLogForTestPass ( string $line ) : boolean
$line string
return boolean

filterFileName() public method

Filter out content from a title any to improve readability of the test name
public filterFileName ( string $filename ) : string
$filename string
return string

filterTitle() public method

This is to improve readability of the test list.
public filterTitle ( string $title ) : string
$title string
return string

getFilename() public method

Get the file Filename
public getFilename ( ) : string
return string

getHash() public method

The hash is the Test title that's been md5'd.
public getHash ( ) : string
return string

getLog() public method

Return the log as a HTML string.
public getLog ( $format = TRUE ) : HTML/Array
$format Split the array into HTML with linebreaks or return as-is if false.
return HTML/Array

getState() public method

Get the Test state based on if the test has run or passed.
public getState ( ) : boolean
return boolean

getTitle() public method

Get the Test title
public getTitle ( ) : string
return string

getType() public method

Get the Test type
public getType ( ) : string
return string

init() public method

Initialization of the Test
public init ( string $type, object $file )
$type string Type of Test
$file object File for the Test

makeHash() public method

Generate a unique hash for the test.
public makeHash ( string $string ) : string
$string string
return string MD5 of $string

passed() public method

Return if the test was run and passed
public passed ( ) : boolean
return boolean

ran() public method

This is deteremined by simply checking the length of the log.
public ran ( ) : boolean
return boolean

reset() public method

Reset a Test back to default.
public reset ( )

setFailed() public method

Sets passed to false if test fails
public setFailed ( )

setLog() public method

Also check the log line may indicate if the Test has passed.
public setLog ( $lines = [] )

setPassed() public method

Set if the test has been passed.
public setPassed ( ) : boolean
return boolean