5

I am to write a unit test for a simple extension using hooks with postprocess and formbuild. How can I do it? Please provide some example.

  • This documentation does not explain how to use hooks only showing this: public function hook_civicrm_post($op, $objectName, $objectId, &$objectRef) { // listen to hook_civicrm_post } – Syed Murtaza Hussain Kazmi Jul 20 '18 at 19:04
1

An example is in tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php, testing that hook_civicrm_tokenValues works correctly on PDF letters.

You write a function using the hook, but you can name it whatever you want. Then you call $this->hookClass->setHook, specifying the function name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.