-
Create the fixture directory.
mkdir tests/events/deployment
Use the GitHub event name as the directory name. For action variants, append _{action} (e.g. pull_request_merged, issues_closed).
-
Write the event type file.
echo -n 'deployment' > tests/events/deployment/type.txt
Bare event type only — no action suffix, no trailing newline required.
-
Write the payload file.
Copy a real payload from log/ (structure is {"repo":"...","event":"...","data":{...}}; use the data value) or from GitHub docs. Save as tests/events/deployment/payload.json. Validate:
php -r "json_decode(file_get_contents('tests/events/deployment/payload.json')); echo json_last_error();"
Must print 0.
-
Determine the expected text.
Instantiate GithubMessageBuilder with the event type and payload, call build()['text'], and save the result:
$builder = new GithubMessageBuilder('deployment', json_decode(file_get_contents('tests/events/deployment/payload.json'), true));
echo $builder->build()['text'];
Or generate it via a quick CLI script and write to tests/events/deployment/expected_text.txt.
-
Verify the fixture passes.
vendor/bin/phpunit
All tests must pass. The fixture is picked up automatically via DirectoryIterator on tests/events/.