PHP Class Psecio\Parse\Rule\RuleTestCase

Inheritance: extends PHPUnit_Framework_TestCase
Show file Open project: psecio/parse

Protected Properties

Property Type Description
$parser The parser to use to parse samples

Public Methods

Method Description
assertParseTest ( mixed $expected, string $code, string $message = '' ) Assert that running $test against $code results in $expected
assertParseTestFalse ( string $code, string $message = '' ) Assert that parsing $code with buildTest()'s Test returns false
assertParseTestTrue ( string $code, string $message = '' ) Assert that parsing $code with buildTest()'s Test returns true
parseSampleProvider ( ) : array PHPUnit provider to provide samples and results
setUp ( ) Set up the parser the same way the Scanner does
testDescription ( )
testLongDescription ( )
testParseSample ( ) Run the tests supplied by {@see parseSampleProvider()}

Protected Methods

Method Description
buildTest ( ) : Psecio\Parse\RuleInterface Method to create the test to evaluate
formatCodeForMessage ( string $code ) : string Format a code string so it displays nicely in an assertion message
scan ( string $code ) : boolean Scan PHP code and return the result

Method Details

assertParseTest() public method

Note taht $message does not replace the message from the assertion, only augments it.
public assertParseTest ( mixed $expected, string $code, string $message = '' )
$expected mixed The expected result of the $test
$code string The PHP code to parse and evaulate
$message string Message to be displayed on failure

assertParseTestFalse() public method

Assert that parsing $code with buildTest()'s Test returns false
public assertParseTestFalse ( string $code, string $message = '' )
$code string Code to test
$message string Message to display on failure

assertParseTestTrue() public method

Assert that parsing $code with buildTest()'s Test returns true
public assertParseTestTrue ( string $code, string $message = '' )
$code string Code to test
$message string Message to display on failure

buildTest() abstract protected method

This should return an instantiated object of the class that is being evaluated
abstract protected buildTest ( ) : Psecio\Parse\RuleInterface
return Psecio\Parse\RuleInterface An object of the type being tested

formatCodeForMessage() protected method

Prefixes each line of the code with " > ".
protected formatCodeForMessage ( string $code ) : string
$code string The code to format
return string The formatted code

parseSampleProvider() public method

This method provides a list of samples and expected results that this unit test should test against. The structure should be: [ ['valid php code', ], [ ... ], ... ] Note that the actual test method prefixes the sample code with '
public parseSampleProvider ( ) : array
return array Lists of samples to test against

scan() protected method

Scan PHP code and return the result
protected scan ( string $code ) : boolean
$code string The code to scan
return boolean The results visiting all the nodes from the parsed $code

setUp() public method

Set up the parser the same way the Scanner does
public setUp ( )

testDescription() public method

public testDescription ( )

testLongDescription() public method

public testLongDescription ( )

testParseSample() public method

Run the tests supplied by {@see parseSampleProvider()}
public testParseSample ( )

Property Details

$parser protected property

The parser to use to parse samples
protected $parser