PHP Unit Testing Like Jasmine
This is legacy material. Now I recommend PHP testing using my Easy Testing of PHP system.
So, for fun I coded a Jasmine-like test runner in PHP.
I suggest that you read the Jasmine introductory notes that I linked to above since they explain the concepts very well in a short read.
The test code is self-documenting i.e. the names of the test functions read like English words that make sense of what is happening in the test code.
It runs through a series of tests that you group into blocks (suites of tests) that are encased in a global describe function. For example, a test suite could be called "Data Access".
Test specs define the various tests that you want to be run and are named with the name of the test suite.
I posted my code to Bit Bucket (see the link at the end of this post) so that you may download or clone it as a Git Repository. Also, you can see how I incorporated unit tests into my Otaku Pro project by browsing the source code.
The main difference in the test Spec format is:
expect('this').toEqual('that'); becomes: expect('this'); toEqual('that');
The PHP implementation also entails using several global variables, so it's important that the names of the functions and global variables don't clash with those used in the code being tested.
If they do (unlikely), it should be easily spotted by exception errors being thrown, then the best course of action would be to rename the items in the code under test.
The tests are ideally run as part of the build process. The output is in the form of green success messages, and the script terminates after any failed test with a red warning message.