Commands
The architecture check
composer run test:arch runs the PHPat rules through PHPStan. These cover flow
runtime isolation, handler versioning, ID strategy, messaging boundaries and
migration isolation. Dependency direction and tenant-aware execution have no PHPat
rule, so they are checked in review.
The default PHPUnit run covers PHPat indirectly through
tests/Unit/Architecture/MigrationTest.php, which invokes PHPStan. The low-level
equivalent is:
What to cover
A node handler should be tested for what it returns, not for what it does internally: the status, thesourceHandle for each outcome, and the
stateChanges it produces. Those three are the contract; everything else is
implementation.
Retry safety deserves its own test. Run execute() twice with the same input
and assert the external effect happened once — this is the failure that only
appears in production, under load, at the worst time.
A data accessor should be tested for supportedKeys() matching what get()
actually answers. A key listed but unanswered passes flow validation and fails at
runtime.
Tenant isolation matters wherever your code touches persistence. A test that
sets up two tenants and asserts one cannot see the other’s rows is worth more than
several tests of the happy path.
Testing a Solution package
A Solution is not an application: its tests run inside a checkout of Core, against the real application, with the package installed by the composer overlay. Core ships a testing kit for that, under theFapost\Testing namespace. A Solution’s tests use the
kit, Foundation and Laravel — never a use App\…, Database\… or Tests\… class of Core. Those
are Core’s internals and change without notice; the kit is what Core keeps working for you.
A working example of everything below is the public
Hello World Solution.
Bootstrap
PHPUnit has to find Core before the kit can be loaded, so the package’stests/bootstrap.php
locates it — from FAPOST_CORE_PATH, or by walking up from the package to the first directory with
artisan and vendor/autoload.php — and hands the rest to the kit:
tests/bootstrap.php
PackageAutoloader::register() maps the autoload and autoload-dev namespaces of your
composer.json onto your checkout, ahead of Core’s own autoloader. Your test classes become
loadable, and tests run from a git worktree of the package exercise that worktree’s src/.
The environment goes in phpunit.xml: both connections on in-memory SQLite and the single-tenant
mode, and the optional services off — the settings Core’s own phpunit.xml uses.
phpunit.xml
The test case
ExtendFapost\Testing\SolutionTestCase. It boots Core, migrates a fresh database with one
tenant, main, renders pages without a Vite manifest, and points the web root at a throwaway
directory, so publishing your bundle never touches Core’s public/.
Each method that changes what a tenant can see also clears what Core remembers within one request,
so the next request in the test sees the change, as a real one would.
ActionCallResult carries success, body and errorCode, with assertSucceeded() and
assertRefused(string $errorCode). An action of a Solution the tenant has not activated is
refused with solution_inactive.
What the kit does not wrap is public already: the installed catalog is Foundation’s
InstalledSolutionCatalogInterface, the manifest check is php artisan platform:update --validate-only, and your provider is $this->app->getProvider(...).
tests/Feature/HelloWorldSolutionTest.php
In CI
Your package’s CI checks Core out, checks the package out under Core’spackages/ directory,
installs Core with the package through the overlay, and runs the tests as above. The Hello World
Solution’s workflow does exactly that, against Core’s main and its latest release. The kit is
part of Core, so a package is always tested against the kit of the Core it runs in.