"CacheManager can not be injected" error when using testing framework
brotkrueml opened this issue · comments
Current behavior
Having a functional test case using the testing framework (v7 branch) and testing an extension which uses EXT:schema as dependency the following error is thrown:
1) MyVendor\MyExtension\Tests\Functional\Domain\Repository\MyRepositoryTest::findBySomething
TYPO3\CMS\Core\Cache\CacheManager can not be injected/instantiated during ext_localconf.php/TCA/ext_tables.php loading. Use lazy loading instead.
This is due the definition of the web page types field in TCA for pages where the WebPageTypeProvider
is used to get the registered web page types. The provider uses the caching framework to get those entries which is to early at least in the testing framework. In daily work in the backend everything works as expected.
Expected behavior/output
No error is thrown.
Steps to reproduce
Write a functional test case which adds the schema extension via class property $testExtensionsToLoad
. Run the test and - boom.
Environment
- schema version: 2.6.1
- TYPO3 version: 11.5.17
- Is your TYPO3 installation set up with Composer (Composer Mode): yes
Possible Solution
Avoid using the schema core cache. As the TCA is stored in cache at warmup (or first hit) the schema core cache may not be needed.