Answer the question
In order to leave comments, you need to log in
What am I doing wrong when calling $this->client->loginUser in a test in Symfony 5.3?
Hey guys.
Symfony 5.3
What am I doing wrong when calling $this->client->loginUser
in a test?
class DbWebTestCase extends WebTestCase
{
...
protected function setUp(): void
{
$this->client = static::createClient();
$this->client->disableReboot();
$kernel = self::bootKernel();
DatabasePrimer::prime($kernel);
$this->em = $kernel->getContainer()->get('doctrine')->getManager();
}
public function test_userinfo_success()
{
$userRepository = $this->em->getRepository(User::class);
$testUser = $userRepository->findOneBy(['email' => '[email protected]']);
// ТУТ РУГАЕТСЯ
$this->client->loginUser($testUser);
}
...
protected function setUp(): void
{
$this->client = static::createClient();
$this->client->disableReboot();
$this->em = static::getContainer()->get('doctrine')->getManager();
}
public function test_userinfo_success()
$userRepository = $this->em->getRepository(User::class);
$testUser = $userRepository->findOneBy(['email' => '[email protected]']);
$this->client->loginUser($testUser);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question