I am trying to setup a test env for Pimcore so that I can use functional tests involving data objects. I followed these steps in the docs: https://pimcore.com/docs/pimcore/current/Development_Documentation/Development_Tools_and_Details/Testing/Application_Testing.html#page_Bootstrapping-Pimcore
I used the KernelTestCase and added the new parameters to the phpunit.xml.dist file.
However I run into several errors:
- the path to the autoloader in bootstrap.php seems incorrect (but maybe this is also a setup error):
include(…/…/vendor/autoload.php): failed to open stream: No such file or directory
When changing this to
include "vendor/autoload.php";it works, but I run into the next issue:
Error: Call to a member function getContainer() on null /Users/bastian/src/pers/api/vendor/pimcore/pimcore/lib/Pimcore.php:204 /Users/bastian/src/pers/api/vendor/pimcore/pimcore/lib/Db.php:52 /Users/bastian/src/pers/api/vendor/pimcore/pimcore/lib/Model/Dao/AbstractDao.php:33 /Users/bastian/src/pers/api/vendor/pimcore/pimcore/lib/Model/AbstractModel.php:117 /Users/bastian/src/pers/api/vendor/pimcore/pimcore/lib/Model/AbstractModel.php:52 /Users/bastian/src/pers/api/vendor/pimcore/pimcore/models/DataObject/ClassDefinition.php:219 /Users/bastian/src/pers/api/vendor/pimcore/pimcore/models/DataObject/Concrete.php:421 /Users/bastian/src/pers/api/var/classes/DataObject/Product.php:513 /Users/bastian/src/pers/api/tests/AppBundle/Twig/Extension/PrepareVariantRenderingExtensionTest.php:25
This is exactly the error I got before switching to the KernelTestCase.
I am able to monkeypatch this by adding these lines into bootstrap.php:
$kernel = \Pimcore\Bootstrap::kernel(); \Pimcore::setKernel($kernel);
This makes tests run, but it still seems that it’s not really correct, since after the test output I get more errors:
THE ERROR HANDLER HAS CHANGED! Remaining indirect deprecation notices (3) 1x: The "Symfony\Component\Debug\Debug" class is deprecated since Symfony 4.4, use "Symfony\Component\ErrorHandler\Debug" instead. 1x in Bootstrap::kernel from Pimcore 1x: The "Symfony\Component\Debug\ErrorHandler" class is deprecated since Symfony 4.4, use "Symfony\Component\ErrorHandler\ErrorHandler" instead. 1x in Bootstrap::kernel from Pimcore 1x: The "Symfony\Component\Debug\BufferingLogger" class is deprecated since Symfony 4.4, use "Symfony\Component\ErrorHandler\BufferingLogger" instead. 1x in Bootstrap::kernel from Pimcore
What am I doing wrong?
Thanks in advance!