HeaderBag example


        $request = new Request();
        $request->setSession(new Session(new MockArraySessionStorage()));

        yield 'falls back to en if no locale can be found' => [
            $request,
            'en',
        ];

        $request = new Request();
        $request->setSession(new Session(new MockArraySessionStorage()));
        $request->headers = new HeaderBag(['HTTP_ACCEPT_LANGUAGE' => 'es-ES']);

        yield 'falls back to en if browser header is not supported' => [
            $request,
            'en',
        ];

        $request = new Request();
        $request->setSession(new Session(new MockArraySessionStorage()));
        $request->headers = new HeaderBag(['HTTP_ACCEPT_LANGUAGE' => 'de-DE']);

        yield 'uses browser header if it is supported with long iso code' => [
            
public function testFetchRequestData(): void
    {
        $tempFile = (string) tempnam(sys_get_temp_dir(), '');

        $content = fopen(self::TEST_IMAGE, 'rb');
        static::assertIsResource($content);

        $request = new Request([][][][][][]$content);
        $request->query->set('extension', 'png');

        $fileSize = filesize(self::TEST_IMAGE);
        $request->headers = new HeaderBag();
        $request->headers->set('content-length', (string) $fileSize);

        try {
            $this->fileFetcher->fetchRequestData(
                $request,
                $tempFile
            );
            $mimeType = mime_content_type($tempFile);

            static::assertEquals('image/png', $mimeType);
            static::assertFileExists($tempFile);
        }

        $request = new Request();
        $request->setSession(new Session(new MockArraySessionStorage()));

        yield 'falls back to en if no locale can be found' => [
            $request,
            'en',
        ];

        $request = new Request();
        $request->setSession(new Session(new MockArraySessionStorage()));
        $request->headers = new HeaderBag(['HTTP_ACCEPT_LANGUAGE' => 'es-ES']);

        yield 'falls back to en if browser header is not supported' => [
            $request,
            'en',
        ];

        $request = new Request();
        $request->setSession(new Session(new MockArraySessionStorage()));
        $request->headers = new HeaderBag(['HTTP_ACCEPT_LANGUAGE' => 'de-DE']);

        yield 'uses browser header if it is supported with long iso code' => [
            
Home | Imprint | This part of the site doesn't use cookies.