psecio/parse — pull request #23 by redbeardcreator (2014-12-29 23:25:05+00:00)
Title: Add "unit" tests that test against parsed code

Implements Issue #22.

Under `tests/Psecio/Parse`, implemented `ParseTest.php`,
`ParseTestVisitor.php` and `Tests/TestSessionRegenFalse_ParseTest.php` (yeah,
crazy name there. May need to figure out a better naming convention).

* `ParseTest.php` implements an abstract base class for all the parsing-based
tests.
* `ParseTestVisitor.php` implements a simple parse tree visitor for use in
testing.
* `Tests/TestSessionRegenFalse_ParseTest.php` implements several parse string
tests for `TestSessionRegenFalse`, including one for the problem I found and
fixed in PR #15.
* `Tests/TestAvoidGlobalsUse_ParseTest.php` implements parse string tests for
`TestAvoidGlobalsUse`.

Implementing a test is as simple as creating a test case that extends
`\tests\Psecio\Parse\ParseTest`. It must implement `parseSampleProvider()` and
`buildTest()`. The `buildTest()` method should return an instance of the unit
under test (e.g. `TestSessionRegenFalse`). Then `parseSampleProvider()` should
return a list of PHP code string (with initial `