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

Allow kernel configuration via data provider #12

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

jdreesen
Copy link
Member

This follows #8 and #11 and adds support for configuring the kernel via data providers:

use Neusta\Pimcore\TestingFramework\Test\Attribute\ConfigureExtension;
use Neusta\Pimcore\TestingFramework\Test\ConfigurableKernelTestCase;

class SomeTest extends ConfigurableKernelTestCase 
{
    public function provideTestData(): iterable
    {
        yield [
            'some value', 
            new ConfigureExtension('some_extension', ['config' => 'some value']),
        ];

        yield [
            new ConfigureExtension('some_extension', ['config' => 'other value']), 
            'other value',
        ];
    }

    /** @dataProvider provideTestData */
    public function test_something(string $expected): void
    {
        self::assertSame($expected, self::getContainer()->getParameter('config'));
    }
}

All kernel configuration objects (RegisterBundle, ConfigureContainer, ConfigureExtension, and RegisterCompilerPass) can be used and are removed from the arguments passed to the test method, so their position doesn't matter.

@jdreesen jdreesen force-pushed the configurable-kernel-via-data-provider branch from c2cfc19 to 0ac7abd Compare March 25, 2024 09:23
@jdreesen jdreesen merged commit ddfc546 into main Mar 25, 2024
4 checks passed
@jdreesen jdreesen deleted the configurable-kernel-via-data-provider branch March 25, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants