Answer the question
In order to leave comments, you need to log in
How to get configs from services.yaml in tests?
Hello.
Symfony is not my profile )), but it is necessary.
It got stuck and I can't reach the /config/services.yaml configs to use parameters in unit tests.
And there are a kiloton of docks, and I don’t understand what I need to use.
Please tell me how to check it to make it work.
class MyTest extends WebTestCase
{
private array $params;
// так работать не будет
public function __construct(ParameterBagInterface $params, $name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->params = $params->get('my_config');;
}
}
Answer the question
In order to leave comments, you need to log in
There are two points in the task:
1) it is not clear whether you configured the
Symfony dock environment to run under test and a note about setting up environments
2) The parameters can be accessed through the container
$client = self::createClient();
$normalContainer = $client->getContainer();
$param = $normalContainer->getParameter('param_name');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question