Add unit test support for plugins#4
Open
saeedvaziry wants to merge 1 commit into
Open
Conversation
Plugin PHP compiles against host VitoDeploy classes (App\Plugins\*, App\SiteFeatures\Action, App\Models\*, the SSH facade) and the host's Tests\TestCase, so tests can't run standalone in this repo. Add a runner that stages each plugin and its tests into a checkout of vitodeploy/vito and runs the host's PHPUnit there. - scripts/test.mjs: stage plugin -> app/Vito/Plugins/<Vendor>/<Name>/ and its tests -> tests/Feature/Plugins/<Vendor>/<Name>/, run host PHPUnit scoped to that dir, clean up. Opt-in per plugin (no tests/ = skipped), required when present. Wired up as `npm test`. - .github/workflows/test.yml: required PR check (read-only, like validate); checks out the host at 4.x, composer install, runs changed plugins' tests. - Example tests for all three plugins + a hello-world starter template. - CONTRIBUTING.md "Test your plugin" section; DESIGN.md decision recorded. tests/ is already excluded from the published artifact, so test files never ship.
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.
What
Adds PHP unit-testing support for plugins. Plugin code compiles against host VitoDeploy classes (
App\Plugins\*,App\SiteFeatures\Action,App\Models\*, theSSHfacade) and the host'sTests\TestCase, so tests can't run standalone in this repo. This wires up a runner that stages each plugin into a checkout ofvitodeploy/vitoand runs the host's PHPUnit there — giving tests the real host classes and the auto-provisioned$this->server/$this->site.Changes
scripts/test.mjs— for each plugin with atests/dir: derives the host path from the manifest namespace, stages the plugin intoapp/Vito/Plugins/<Vendor>/<Name>/and its tests intotests/Feature/Plugins/<Vendor>/<Name>/, runs the host's PHPUnit scoped to that dir, then cleans up (leaves zero residue). Exposed asnpm test..github/workflows/test.yml— required PR check (read-only token, same trust model asvalidate): checks out the host at4.x,composer install, runs the changed plugins' tests. Failure blocks merge.CONTRIBUTING.md; decision recorded inDESIGN.md.Tests are opt-in per plugin (a plugin with no
tests/is reported as skipped, not failed) but required when present.tests/is already excluded from the published artifact, so test files never ship.Notes for reviewers
pestphp/pestisn't a direct dep ofvitodeploy/vitoand there's nopestbinary, so tests are class-based extendingTests\TestCase, matching the host's actualtests/Featureconvention.Octane Enable::handle()rendersview('ssh.services.webserver.nginx.vhost-blocks.laravel-octane'), which neither the plugin nor the host ships — a full enable throwsView not found. The Octane example test is scoped to the parts the Action owns (validation,active()guard), with the vhost-view dependency documented in a comment. Worth a separate follow-up.4.x; add a matrix overrefto also gate an older line.Verification
validateandpack --dry-runstill pass; pack output confirmed to excludetests/.