Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Kernel for integration tests #8

Merged
merged 16 commits into from
Mar 18, 2024
Merged

Conversation

jdreesen
Copy link
Member

@jdreesen jdreesen commented Mar 11, 2024

Extends the TestKernel so that it 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:

use Neusta\Pimcore\TestingFramework\Kernel\TestKernel;
use Neusta\Pimcore\TestingFramework\Test\ConfigurableKernelTestCase;

class SomeTest 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());
        }]);
    }
}

@jdreesen jdreesen added the enhancement New feature or request label Mar 11, 2024
@jdreesen jdreesen force-pushed the configurable-kernel branch 4 times, most recently from 65d2244 to 6045058 Compare March 11, 2024 18:08
Copy link
Member

@yariksheptykin yariksheptykin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, @jdreesen . Let's merge this in.

tests/app/.env Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
This hides the "Multiple definitions exist for class 'TestKernel'"
inspection message in PHPStorm.
@jdreesen jdreesen merged commit a10fb7f into main Mar 18, 2024
4 checks passed
@jdreesen jdreesen deleted the configurable-kernel branch March 18, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants