Project

General

Profile

Actions

Testing

Writing & Running Tests

  • Make a new file in the tests folder of the working directory. The file should be named after the file in which you are testing plus "Test"
    • i.e. testing StuffFinder.php => StuffFinderTest.php
  • Name the function after the function you are testing, plus "Test"
    • i.e. testing findStuff() => findStuffTest()
  • Can only test public functions
    • if needed, step through the call stack to find a public function that is higher up in the stack than the desired private/protected function you want to test
  • To run a unit test, use this command: env CIVICRM_UF=UnitTests XDEBUG_SESSION=VSCODE phpunit7 (absolute path to file where test is written) --filter (name of test function) (subbing in the correct content within the parenthesis to the relevant info for your particular test)

Updated by Brienne Kordis 2 months ago · 6 revisions