generateAccountRecovery example

$request = $this->createRequest('frontend.account.recover.request');

        $data = new RequestDataBag([
            'email' => new RequestDataBag([
                'email' => $customer->getEmail(),
            ]),
        ]);

        $this->getContainer()->get('request_stack')->push($request);

        $response = $controller->generateAccountRecovery($request$data$this->salesChannelContext);

        $this->getContainer()->get('event_dispatcher')->removeSubscriber($testSubscriber);

        /** @var FlashBag $flashBag */
        $flashBag = $this->getSession()->getBag('flashes');

        static::assertEquals(302, $response->getStatusCode());
        static::assertCount(1, $flashBag->get(StorefrontController::SUCCESS));
        static::assertEquals('/account/recover', $response->headers->get('location') ?? '');

        // excluded events and its mail events should not be logged
$this->getContainer()->get(LogoutRoute::class),
            $this->getContainer()->get(StorefrontCartFacade::class),
            $this->getContainer()->get(AccountRecoverPasswordPageLoader::class),
            $this->getContainer()->get(SalesChannelContextService::class)
        );
        $controller->setContainer($this->getContainer());

        $request = $this->createRequest('frontend.account.recover.request');

        $this->getContainer()->get('request_stack')->push($request);

        $controller->generateAccountRecovery($requestnew RequestDataBag([
            'email' => [
                'email' => 'test@example.com',
            ],
        ])$this->salesChannelContext);

        $session = $this->getSession();
        static::assertInstanceOf(Session::class$session);
        $flashBag = $session->getFlashBag();

        static::assertNotEmpty($flash = $flashBag->get('info'));
        static::assertEquals($this->translator->trans('error.rateLimitExceeded', ['%seconds%' => 10])$flash[0]);
    }
Home | Imprint | This part of the site doesn't use cookies.