-
Notifications
You must be signed in to change notification settings - Fork 12
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
Injection in ViewHelper is problematic for phpunit functionnal tests #85
Comments
Thank you for this report. Unfortunately, I currently don't have a similar setup to test this. It seems to be a problem with dependency injection in the sub-request. So first some general questions:
|
My setup is a very simple simple from which we start our project, nothing fancy. Thanks! |
And the extension is loaded in your test using |
Ho. I didn't think of that! I now have I suppose I will just create a mock manifest.json for my functionnal testsé Thanks for the help! |
Ok, I finally got it to work.
{
"Main.entry.js": {
"css": [],
"file": "",
"isEntry": true,
"src": ""
}
}
protected array $pathsToProvideInTestInstance = [
'typo3conf/ext/site_package/Tests/Fixtures/manifest.json' => 'fileadmin/Fixtures/manifest.json',
];
$this->get(ExtensionConfiguration::class)->set('vite_asset_collector', [
'useDevServer' => '0',
'devServerUri' => 'https://localhost:5173',
'defaultManifest' => 'fileadmin/Fixtures/manifest.json',
]);
I don't think there is a "good" way to fix this with the actual code. Something in the viewhelper that could just ignore everything if set; like a "ignore" configuration? Thanks. |
You could also enable the dev server, then probably no files need to exist. |
Yeah, you're right! Just this is enough:
$this->get(ExtensionConfiguration::class)->set('vite_asset_collector', [
'useDevServer' => '1',
]); |
Hi.
Not sure if there is a problem on how I test my things, but I get this error when running my functionnal tests (with TYPO3 testing-framework):
Error: Typed property Praetorius\ViteAssetCollector\ViewHelpers\Asset\ViteViewHelper::$viteService must not be accessed before initialization
I'm in TYPO3 v12.
I use "executeFrontendSubRequest" to call my pages to get the body and test against the result.
The text was updated successfully, but these errors were encountered: