I try to get the kernel root dir in setUp method of unitTest:
private string $databaseDirPath;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$container = static::getContainer();
$this->databaseDirPath = $container->getParameter('kernel.root_dir').'/resources/database/' ;
}
/**
* @dataProvider provideInexistentFile
*/
public function testConvertReturnNull(string $file):void
{
if (!file_exists($file) || !is_readable($file)) {
$response = null;
}
$this->assertNull($response);
}
public function provideInexistentFile(): array
{
return [
'inexistent file' => [
$this->databaseDirPath. 'comdfsasd.csv',
],
'inexistent file' => [
$this->databaseDirPath. 'gbfdgbzsa.csv',
],
];
}
and this the error:
$databaseDirPath must not be accessed before initialization