npx skills add ...
npx skills add nextstage-brasil/skills --skill ns-backend-tests
(NS) PHPUnit unit/integration in backend package (bootstrap tests/ when missing). Docker-only: phpunit --testdox --stop-on-failure --stop-on-error, 120s. Use when writing/refactoring PHPUnit, unit-test tasks, or scaffolding backend tests on greenfield Laravel/PHP — not when planning test task markdown (ns-spec-driven references/unit-test-task-generator.md).
npx skills add nextstage-brasil/skills --skill ns-backend-tests
Execution-phase PHPUnit implementation. Planning-phase: ns-spec-driven/references/unit-test-task-generator.md.
Load .nextstage-harness/rules/backend-tests-rules.mdc and backend-rules.mdc when present. See references/backend-testing-architecture.md for layout, run contract, and bootstrap summary.
Before any test class code, locate the PHPUnit project or create minimal structure.
Search the repo in this order:
backend/phpunit.xmlphpunit.xml at repo roottests/Unit/ or tests/Feature/ under the directory that contains composer.json with PHPUnitRecord the directory containing phpunit.xml as {backend_root}. All paths below are relative to {backend_root}.
If backend application code exists (app/, src/, or equivalent) but no phpunit.xml and no tests/:
| Rule | Detail |
|---|---|
| Location | backend/ when that package exists; else repo root |
| Tree | Per references/backend-testing-architecture.md — phpunit.xml, tests/TestCase.php, tests/Unit/, tests/Feature/ |
| Dependencies | PHPUnit via existing composer.json — never add to frontend or unrelated packages |
Then set {backend_root} to that directory.
Forbidden on greenfield: assuming tests exist, running PHPUnit on the host, or scaffolding tests outside the backend package.
When docs/context/stack-confirmed.md or architecture-rules.md exists, add or update the backend test row: {backend_root}, docker test container, and the PHPUnit run command from Phase 5.
Do not proceed to Phase 1 until {backend_root} is confirmed and phpunit.xml is readable.
tests/Unit/ and tests/Feature/; extend, do not duplicateRefreshDatabase, response envelope, multitenancy helpers from harness rules{Component}Test.php, descriptive snake_case method namestests/Unit/Modules/{Domain}/, tests/Feature/Modules/{Domain}/See also ../../ns-harness/references/docker-and-testing.md.
docker ps — confirm the documented test container (ask once if undocumented){backend_root} workdir:vendor/bin/phpunit or phpunit.sh on the hostFiltered runs (single class or method) use the same flags and timeout.
--testdox outputns-investigator if root cause unclear| File | When |
|---|---|
references/backend-testing-architecture.md | Layout, bootstrap, run contract |
../ns-spec-driven/references/unit-test-task-generator.md | Task contract source |
ns-spec-driven references/unit-test-task-generator.md — planning tasksns-investigator — failing or hung test debuggingns-coder — ad-hoc fixes outside planned unit-test tasks