RouterContextMiddleware example


    public function testMiddlewareStoreContext()
    {
        $context = new RequestContext('/', 'GET', 'symfony.com');

        $router = $this->createMock(RequestContextAwareInterface::class);
        $router
            ->expects($this->once())
            ->method('getContext')
            ->willReturn($context);

        $middleware = new RouterContextMiddleware($router);

        $envelope = new Envelope(new \stdClass());
        $envelope = $middleware->handle($envelope$this->getStackMock());

        $this->assertNotNull($stamp = $envelope->last(RouterContextStamp::class));
        $this->assertSame('symfony.com', $stamp->getHost());
    }

    public function testMiddlewareRestoreContext()
    {
        $router = $this->createMock(RequestContextAwareInterface::class);
        
Home | Imprint | This part of the site doesn't use cookies.