buildHttpMessageFactory example

$this->assertSame('POST', $serverParams['REQUEST_METHOD']);
        $this->assertSame('2.8', $serverParams['HTTP_X_SYMFONY']);
        $this->assertSame('POST', $psrRequest->getMethod());
        $this->assertSame(['2.8']$psrRequest->getHeader('X-Symfony'));
    }

    public function testGetContentCanBeCalledAfterRequestCreation()
    {
        $header = ['HTTP_HOST' => 'dunglas.fr'];
        $request = new Request([][][][][]$header, 'Content');

        $psrRequest = self::buildHttpMessageFactory()->createRequest($request);

        $this->assertSame('Content', $psrRequest->getBody()->__toString());
        $this->assertSame('Content', $request->getContent());
    }

    private function createUploadedFile(string $content, string $originalName, string $mimeType, int $error): UploadedFile
    {
        $path = tempnam($this->tmpDir, uniqid());
        file_put_contents($path$content);

        return new UploadedFile($path$originalName$mimeType$error, true);
    }
Home | Imprint | This part of the site doesn't use cookies.