[3.0] Feature/plugin test support#5819
Open
ralf1070 wants to merge 2 commits into
Open
Conversation
- Kernel: support LOAD_PLUGINS_IN_TEST env var ($_ENV and $_SERVER)
to selectively load plugins in the test environment
- bin/test-plugins: discover and run all plugin test suites
- Clear test cache with APP_DEBUG=0 before each suite (matches
PHPUnit non-debug container)
- Pass LOAD_PLUGINS_IN_TEST with all discovered plugins
- Plugin bootstrap.php handles its own schema needs
- composer.json: add tests-plugins script
31a4824 to
56897a1
Compare
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.
Summary
Adds infrastructure for testing Kimai plugins within the main Kimai test environment:
LOAD_PLUGINS_IN_TESTenv var inKernel::registerBundles()controls which plugins are loaded during tests. Accepts a comma-separated list of bundle names (e.g.RemoteWorkBundle,WorkContractBundle). Without it, behavior is unchanged — no plugins are loaded in thetestenvironment.bin/test-pluginsscript: Standalone PHP script that discovers all installed plugins with aphpunit.xmlandTests/directory, then runs PHPUnit for each one. Supports--plugin <name>to run a single plugin's tests. Extra CLI arguments are passed through (e.g.bin/test-plugins --filter testSomething). Disabled plugins (.disabledmarker) are skipped.composer tests-plugins: Composer script entry pointing tobin/test-plugins, consistent with existingcomposer tests,tests-unit, andtests-integration.$_ENV/$_SERVERcompatibility: Checks both$_ENVand$_SERVERforLOAD_PLUGINS_IN_TEST, since PHPUnit<env force="true">sets$_ENVwhile Docker/shellenvsets$_SERVER.phpunit.xml.dist: Removedforce="true"fromDATABASE_URLso an existing environment variable (e.g. from a Docker container) takes precedence over the default.Two-level test architecture
The test infrastructure uses a two-level approach to separate central concerns from plugin-specific needs:
Level 1:
bin/test-plugins(central baseline)Before each plugin suite, the script establishes a clean baseline:
APP_DEBUG=0(matching PHPUnit's non-debug container) and all plugins loaded viaLOAD_PLUGINS_IN_TESTcomposer tests) have run with a different container configurationLevel 2: Plugin
bootstrap.php(plugin-specific)Each plugin's bootstrap handles its own needs, e.g.:
doctrine:schema:update --forceto ensure plugin-specific tables exist (idempotent — creates missing tables after core test reset, no-op when current)BOOTSTRAP_RESET_DATABASE=true)This separation means
bin/test-pluginsdoesn't need to know about plugin-specific database schemas, and plugins don't need to worry about cache state.Usage
Plugin phpunit.xml example
Test plan
bin/test-pluginsdiscovers and runs plugin test suitescomposer tests-pluginsinvokesbin/test-plugins--plugin <name>runs only a single plugin's test suitephpunit.xmlorTests/directory are skipped.disabled) are skippedAPP_DEBUG=0before each suite (prevents stale non-debug container)Types of changes
Checklist
composer code-check)