@EVOSandru6

Что не так делаю при вызове $this->client->loginUser в тесте в Symfony 5.3?

Привет, ребят.
Symfony 5.3
Что не так делаю при вызове $this->client->loginUser в тесте?

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' => 'black.jack@mail.ru']);

    // ТУТ РУГАЕТСЯ
    $this->client->loginUser($testUser);
}
...


LogicException: Cannot retrieve the container from a non-booted kernel.

Если делаю следующим образом:

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' => 'black.jack@mail.ru']);
        $this->client->loginUser($testUser);
}


Ловлю следующую ошибку:

You have requested a non-existent service "security.untracked_token_storage"
  • Вопрос задан
  • 313 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы