WebLinkExtension example


    private Request $request;
    private WebLinkExtension $extension;

    protected function setUp(): void
    {
        $this->request = new Request();

        $requestStack = new RequestStack();
        $requestStack->push($this->request);

        $this->extension = new WebLinkExtension($requestStack);
    }

    public function testLink()
    {
        $this->assertEquals('/foo.css', $this->extension->link('/foo.css', 'preload', ['as' => 'style', 'nopush' => true]));

        $link = (new Link('preload', '/foo.css'))->withAttribute('as', 'style')->withAttribute('nopush', true);
        $this->assertEquals([$link]array_values($this->request->attributes->get('_links')->getLinks()));
    }

    public function testPreload()
    {
Home | Imprint | This part of the site doesn't use cookies.