StorefrontRedirectEvent example

$this->addFlash($type$message);
            }
        }
    }

    /** * @param array<string, mixed> $parameters */
    protected function redirectToRoute(string $route, array $parameters = [], int $status = Response::HTTP_FOUND): RedirectResponse
    {
        $event = new StorefrontRedirectEvent($route$parameters$status);
        $this->container->get('event_dispatcher')->dispatch($event);

        return parent::redirectToRoute($event->getRoute()$event->getParameters()$event->getStatus());
    }

    /** * @param array<string, mixed> $parameters */
    protected function renderView(string $view, array $parameters = []): string
    {
        $view = $this->getTemplateFinder()->find($view);

        
/** * @internal * * @covers \Shopware\Storefront\Event\StorefrontRedirectEvent */
#[Package('storefront')] class StorefrontRedirectEventTest extends TestCase
{
    public function testMinimalConstructor(): void
    {
        $event = new StorefrontRedirectEvent('test_route');

        static::assertSame('test_route', $event->getRoute());
        static::assertSame([]$event->getParameters());
        static::assertSame(Response::HTTP_FOUND, $event->getStatus());
    }

    public function testConstructor(): void
    {
        $event = new StorefrontRedirectEvent('test_route', ['test_parameter' => 'test_value'], 500);

        static::assertSame('test_route', $event->getRoute());
        
$container = new ContainerBuilder();
        $container->set(ScriptExecutor::class$executor);

        $this->controller->setContainer($container);

        $this->controller->testHook($hook);
    }

    public function testRedirectEvent(): void
    {
        $event = new StorefrontRedirectEvent('test_route', ['test' => 'param']);

        $dispatcher = static::createMock(EventDispatcherInterface::class);
        $dispatcher
            ->expects(static::once())
            ->method('dispatch')
            ->with(static::equalTo($event));

        $router = static::createMock(RouterInterface::class);
        $router
            ->expects(static::once())
            ->method('generate')
            
Home | Imprint | This part of the site doesn't use cookies.