how to write PHP Unit test for an entity using hooks
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.