expectOutputString example

// prepare a request for a range of the testing file         $request = Request::create('/');
        $request->headers->set('If-Range', $etag);
        $request->headers->set('Range', $requestRange);

        $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r');
        fseek($file$offset);
        $data = fread($file$length);
        fclose($file);

        $this->expectOutputString($data);
        $response = clone $response;
        $response->prepare($request);
        $response->sendContent();

        $this->assertEquals(206, $response->getStatusCode());
        $this->assertEquals($responseRange$response->headers->get('Content-Range'));
        $this->assertSame((string) $length$response->headers->get('Content-Length'));
    }

    /** * @dataProvider provideRanges */
$context = Context::createDefaultContext();
        $fileRepository->create([$fileData]$context);

        $downloadService = new DownloadService($filesystem$fileRepository);
        $accessToken = $downloadService->regenerateToken($context$fileData['id']);

        $response = $downloadService->createFileResponse($context$fileData['id']$accessToken);
        static::assertIsString($header = $response->headers->get('Content-Disposition'));
        static::assertStringContainsString($asciiName$header);

        $response->sendContent();
        $this->expectOutputString($fileData['originalName']);
    }

    public function testSlashFilename(): void
    {
        $filesystem = $this->getPrivateFilesystem();
        $fileRepository = $this->getContainer()->get('import_export_file.repository');

        $nameWithSlash = 'Name with /\/\/\ slashes';

        $fileData = [
            'id' => Uuid::randomHex(),
            
Home | Imprint | This part of the site doesn't use cookies.