pimcore v 6.6
im trying to unit test by codeception, i have installed codception and tests/ folder created under my project directory. But when im calling the service function getting below error
Error attached
**[PHPUnit\Framework\Exception] Use of undefined constant PIMCORE_PROJECT_ROOT - assumed ‘PIMCORE_PROJECT_ROOT’ (this will throw an Error in a future version of PHP)
src/GenericBundle/Service/PdfImportService.php:31**
File name for test is PdfImportServiceTest.php
public function testGetFilesArray() {
$pdfService = new PdfImportService();
$this->assertFalse($pdfService->getFilesArray());
}
I have added bootstrap.php file inside tests/ path
code is here
// tests/bootstrap.php
include “./vendor/autoload.php”;
\Pimcore\Bootstrap::setProjectRoot();
\Pimcore\Bootstrap::bootstrap();
===================================================
added another file named codeception.dist.yml
namespace: Tests support_namespace:
Support actor_suffix: Tester
paths:
tests: .
output: ./_output
data: ./Support/Data
support: ./Support
envs: ./_envs
settings:
bootstrap: _bootstrap.php
colors: true
params: - env
extensions:
enabled: - Codeception\Extension\RunFailed
============================================================= also i have added _bootstrap.php && codeception.yml file inside tests/ as per in the pimcore doc
when im executing this test case, its calling constructor of actual service file and there we have defined constant path for the file, but this test case is not working. Actual function from the backend is working
in some services im getting get container null error… Please check the link for error.
I followed pimcore unit testing document + symfony documnet + codception document. But it didnt work for me. Im stuck with this from 3 days.
Please let me know how to resolve it.
Thanks in advance

