@@ -30,6 +30,8 @@ Unless explicitly asked otherwise:
3030** Prerequisites:**
3131- Clear cache when changing branches, dependencies, or ` USE_SYMFONY_LISTENERS ` : ` rm -rf tests/Fixtures/app/var/cache/test `
3232- Optionally warm cache: ` tests/Fixtures/app/console cache:warmup `
33+ - For MongoDB tests: Set ` APP_ENV=mongodb ` and install MongoDB ODM: ` composer require --dev doctrine/mongodb-odm-bundle `
34+ - MongoDB extension required: Ensure ` mongodb ` PHP extension is installed
3335
3436** PHPUnit (Main Suite):**
3537``` bash
@@ -83,12 +85,58 @@ vendor/bin/behat --profile=default --tags '~@!mysql' --format=progress
8385vendor/bin/behat --format=progress
8486```
8587
88+ ** MongoDB Tests:**
89+ ``` bash
90+ # Set MongoDB environment
91+ export APP_ENV=mongodb
92+ export MONGODB_URL=mongodb://localhost:27017
93+
94+ # Install MongoDB ODM
95+ composer require --dev doctrine/mongodb-odm-bundle
96+
97+ # Clear cache (always required when changing APP_ENV)
98+ rm -rf tests/Fixtures/app/var/cache/test
99+
100+ # Run PHPUnit tests (exclude ORM tests)
101+ vendor/bin/phpunit --exclude-group=orm
102+
103+ # Run Behat tests with MongoDB profile
104+ vendor/bin/behat --profile=mongodb-coverage --format=progress
105+ ```
106+
86107** Static Analysis:**
87108``` bash
88109# Always run PHPStan to prevent trivial bugs
110+ # CRITICAL: PHPStan requires MongoDB extension AND MongoDB ODM bundle
111+ # Install MongoDB PHP extension first (e.g., pecl install mongodb)
112+ # Then install MongoDB ODM:
113+ composer require --dev doctrine/mongodb-odm-bundle
89114vendor/bin/phpstan analyse --no-interaction --no-progress
115+
116+ # PHPStan will fail without both:
117+ # - mongodb PHP extension (for analyzing Document fixtures)
118+ # - doctrine/mongodb-odm-bundle package (for ODM classes)
90119```
91120
121+ ** Testing Event Listeners (vs Default Event System):**
122+
123+ API Platform has two modes for handling Symfony events:
124+
125+ 1 . ** Default Mode (Event System):** Uses Symfony's event system with event subscribers
126+ 2 . ** Event Listeners Mode:** Uses traditional Symfony event listeners (enabled with ` USE_SYMFONY_LISTENERS=1 ` )
127+
128+ ** When to test with event listeners:**
129+ - Set ` USE_SYMFONY_LISTENERS=1 ` environment variable
130+ - Always clear cache after switching modes: ` rm -rf tests/Fixtures/app/var/cache/test `
131+ - CI runs separate jobs for both modes to ensure compatibility
132+
133+ ** Special Note - Events vs Non-Events:**
134+ The event listeners mode (` USE_SYMFONY_LISTENERS=1 ` ) changes how API Platform hooks into Symfony's lifecycle:
135+ - ** Non-events (default):** Uses event subscribers for better performance and flexibility
136+ - ** Events (listeners):** Uses traditional event listeners for backward compatibility
137+ - Both modes must be tested to ensure feature compatibility
138+ - When debugging event-related issues, test both modes
139+
92140### Laravel Tests
93141
94142** Setup:**
0 commit comments