From c87c5deda2d59438fc5ffc7ec504a5d4a0a687e0 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Mon, 11 Mar 2024 14:48:09 +0100 Subject: [PATCH] Update changelog & readme --- CHANGELOG.md | 11 +++++------ README.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0998feb..e831fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,16 @@ # Changelog -## v0.11.1 - +## v0.12.0 ### Features +- Dynamically configurable test kernel with which you can register bundles, load configurations, + configure extensions, and register compiler passes for each test. +## v0.11.1 +### Features - Support for Pimcore 11. ## v0.11.0 - ### Breaking Changes: - - `Neusta\Pimcore\TestingFramework\Pimcore\BootstrapPimcore::bootstrap()` now expects named arguments.
If you pass the application environment as a parameter, you now have to prefix it with: `APP_ENV:`: ```diff @@ -22,9 +23,7 @@ - The `WithoutAdminMode` trait was removed. ### Bugfixes: - - Reset admin mode to previous state after each test class when using `WithAdminMode` trait. ### Changes: - - Drop support for Pimcore `<10.5` and PHP `<8.1`. diff --git a/README.md b/README.md index da21a98..c4d8126 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,38 @@ To enable it again, you can use the `WithAdminMode` trait. - `WithInheritedValues` - `WithoutInheritedValues` +### Integration tests with configurable Kernel + +The `TestKernel` can be configured dynamically for each test. +This is useful if different configurations or dependent bundles are to be tested. +To do this, your test class must inherit from `ConfigurableKernelTestCase`: + +```php +use Neusta\Pimcore\TestingFramework\Kernel\TestKernel; +use Neusta\Pimcore\TestingFramework\Test\ConfigurableKernelTestCase; + +class BundleInitializationTest extends ConfigurableKernelTestCase +{ + public function test_bundle_with_different_configuration(): void + { + // Boot the kernel with a config closure + $kernel = self::bootKernel(['config' => static function (TestKernel $kernel) { + // Add some other bundles we depend on + $kernel->addTestBundle(OtherBundle::class); + + // Add some configuration + $kernel->addTestConfig(__DIR__.'/config.yaml'); + + // Configure some extension + $kernel->addTestExtensionConfig('my_bundle', ['some_config' => true]); + + // Add some compiler pass + $kernel->addTestCompilerPass(new MyBundleCompilerPass()); + }]); + } +} +``` + ### Integration Tests With a Database If you write integration tests that use the database, we've got you covered too.