fix: test environment setup for clean Docker installs#115
fix: test environment setup for clean Docker installs#115
Conversation
- Add .env.testing.example pre-configured for Docker Compose local dev - Document .env.testing requirement and stopOnFailure behavior in LOCAL_DEVELOPMENT_HOWTO.md - Update .gitignore to allow .env.testing.example despite .env.* rule - Seed groups API and scopes in TestSeeder so OAuth2GroupApiTest passes in clean environments
4ca7db6 to
3e95207
Compare
|
The "fix" is a duplicate of existing code The PR claims that TestSeeder doesn't seed the groups API and its scopes, causing OAuth2GroupApiTest to fail. This is wrong. The seeders already handle it:
The full TestSeeder::run() flow calls these three seeders before the test-specific seedApis()/seedApiScopes() methods. The groups data is already seeded and nothing downstream deletes it. also The PR adds a groups entry to TestSeeder::seedApis(), but that method creates APIs under "test resource server", while ApiSeeder creates the groups API under "OpenStackId server". This would i am gonna decline this PR , if you want the .env.testing docs, that could be a separate small PR. |
What
Two fixes that make the test suite work correctly in clean Docker environments (i.e. when someone clones the repo fresh and runs the tests for the first time).
1. Fix: seed
groupsAPI and scopes inTestSeederOAuth2GroupApiTestrequests thegroups/read-allandgroups/writescopes during its OAuth2 flow. These scopes are created by a data migration (Version20250731141145), butOpenStackIDBaseTestCasewipesoauth2_api_scopebefore every test run and re-seeds fromTestSeeder— which did not include these scopes.In a clean environment where migrations are run before the tests, the migration is already recorded as applied, so it does not re-run during the test, and the scopes are never restored. Result: 400 on the token endpoint, test fails.
Fixed by adding the
groupsAPI and its two scopes toTestSeederdirectly, following the same pattern used for other APIs.2. Docs: add
.env.testing.exampleand testing instructionsWhen PHPUnit runs, it sets
APP_ENV=testing(viaphpunit.xml), causing Laravel to load.env.testinginstead of.env. This is not documented anywhere, and the missing file produces no clear error — it just silently falls back to.env, which is missing many vars the OAuth2 server depends on.Added:
.env.testing.example— pre-configured for the standard Docker Compose setup, ready to copyLOCAL_DEVELOPMENT_HOWTO.mdexplaining the.env.testingrequirement and thestopOnFailurebehavior.gitignoreto allow.env.testing.exampleto be committed despite the.env.*ruleWhy
Both issues caused
OAuth2GroupApiTest::testGetAllto fail (returning 400 instead of 200) in any clean Docker setup. The root causes were non-obvious and would affect any new contributor setting up the project for the first time.