feat: artisan commands — listen, post, health#34
Merged
Conversation
added 2 commits
April 27, 2026 01:29
Add three artisan commands for the package: - mattermost:health — connectivity check hitting /users/me and /system/ping, prints a status table with auth, ping, version, latency - mattermost:post — one-shot CLI post with channel ID or name resolution (team lookup when a name is given, direct ID when a 26-char ID is given) - mattermost:listen — start the bot WebSocket listener with signal handling, wiring the Bot Router to the WS client All commands accept --connection for multi-server support. Registered in MattermostServiceProvider alongside DemoPostCommand. Includes Pest BDD tests for each command.
The test was hitting a database cache store without a cache table in the in-memory SQLite test database.
There was a problem hiding this comment.
Ship it. Clean artisan commands with good test coverage, nice table output in health, flexible channel resolution in post.
Notes:
connectionName()duplicated x3 — extract totraitshared by all commands.- ListenCommandTest.php ~lines 12-17: dead
assertTrue(... || true)+ unused$command+ bogusApplication::starting()— delete,--helpalready proves registration. - ListenCommandTest ~lines 30-50: tests instantiate deps manually instead of asserting command
handle()invokes them with config — mockWebSocketClient::make()/ router attach or move to Unit/WebSocketClientTest.php + Unit/RouterTest.php.
All nits; tests pass as-is.
There was a problem hiding this comment.
Ship it.
- Artisan commands cover core ops (health check, one-shot post, WS daemon) with smart defaults/multi-connection support.
- Tests solid: Pest BDD mocks Saloon requests accurately, edge cases (no-team, bad-auth, ID-vs-name) covered.
- UX table/output intuitive for CLI.
Nit on ListenCommandTest dead assert inline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #10
Three artisan commands for the package:
mattermost:health [--connection=]— connectivity check. Hits/api/v4/users/meand/api/v4/system/ping, prints a status table (auth ok, ping ok, version, latency).mattermost:post {channel} {message} [--connection=] [--team=]— one-shot post from CLI. Accepts a 26-char channel ID directly or resolves channel-by-name via team lookup.mattermost:listen [--connection=]— start the bot WS listener. Wires the Bot Router to the WebSocket Client, uses signal handling (SIGTERM/SIGINT) for clean shutdown.All commands support
--connectionfor multi-server named connections. Registered inMattermostServiceProvider::boot()alongsideDemoPostCommand.Test plan
vendor/bin/pint --test— passedvendor/bin/pest --compact— 283 passed, 14 skipped (integration)vendor/bin/phpstan analyse— no errors (level 8)vendor/bin/rector process --dry-run— no changesDemo
Demo: http://localhost:8065/jordan-partridge-enterprises-llc/pl/8ghzynca938bfmhdqsy85at5fw