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

[FEATURE] Allow PHP as fixture data provider #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sascha-egerer
Copy link
Contributor

@sascha-egerer sascha-egerer commented May 31, 2023

Add support for PHP files as fixture data provider like ComponentName.fixture.php

Resolves #109

Add support for PHP files as fixture data provider
like `ComponentName.fixture.php`
@sascha-egerer
Copy link
Contributor Author

I have also a neat helper that does render a component that than can be passed to a slot.

Looks like this:

return [
    'default'  => [
        'firstAttribute' => 'value',
        'mySlot' => $fixtureProvider->renderComponentTagWithFixture(componentIdentifier: 'component.abc', fixtureIdentifier: 'default'),
    ]
];

If this one gets merged i may also contribute this helper if you think it does make sende.

Copy link
Member

@ulrichmathes ulrichmathes left a comment

Choose a reason for hiding this comment

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

We have to extend the documentation. But i can do this.

@@ -117,6 +111,9 @@ public function getFixtures(): array
$loader = GeneralUtility::makeInstance(YamlFileLoader::class);
$fixtures = $loader->load($fixtureFile) ?? [];
break;
case 'php':
$fixtures = require $fixtureFile;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should validate that there is an array coming? Also the other cases take care of failures and set to empty array.

I think both could achieved with this array cast?

Suggested change
$fixtures = require $fixtureFile;
$fixtures = (array) require $fixtureFile;

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.

Allow "php" as fixture type
2 participants