-
Notifications
You must be signed in to change notification settings - Fork 0
Automated testing
A focus going forward is to increase the automated test coverage for the system.
Tests are run through the command line php app/tests/run.php USER
where USER
is the user ID to use to run the tests.
If all tests are run you should be left with a working blog, if an error occurs during running the tests then no further tests will be run.
The test process uses the hook system to run through all tests, new tests can be added by adding a runUnitTests
function (poorly named as most of these tests are not unit tests...) to a modules Module.php
file. When run.php is executed it calls the runUnitTests
hook, passing through a context
argument so that modules can add tests to run after another. The context
argument is set to "root"
to start with, the Blog and BlogPosts (as examples) also call the runUnitTests
hook passing in additional arguments for other modules to use. For example, the BlogPosts module implements tests that use the blog created in CreateBlogTest
(Blog module) so not to have to duplicate the process of creating a blog.
Each test should be placed under the src/tests directory of a module, and extend the \HamletCMS\tests\TestResult
class which sets up fake request and response objects for you to use in the test. The code to run the test should be added to a public run
method and print
details of test failure/ success.