public function FileUploadTest::testFileUploadUnicodeFilename in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::testFileUploadUnicodeFilename()
- 9 core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::testFileUploadUnicodeFilename()
Tests using the file upload route with a unicode file name.
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ FileUploadTest.php, line 528
Class
- FileUploadTest
- Tests binary data file upload route.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testFileUploadUnicodeFilename() {
$this
->setUpAuthorization('POST');
$this
->config('jsonapi.settings')
->set('read_only', FALSE)
->save(TRUE);
$uri = Url::fromUri('base:' . static::$postUri);
// It is important that the filename starts with a unicode character. See
// https://bugs.php.net/bug.php?id=77239.
$response = $this
->fileRequest($uri, $this->testFileData, [
'Content-Disposition' => 'file; filename="Èxample-✓.txt"',
]);
$this
->assertSame(201, $response
->getStatusCode());
$expected = $this
->getExpectedDocument(1, 'Èxample-✓.txt', TRUE);
$this
->assertResponseData($expected, $response);
$this
->assertSame($this->testFileData, file_get_contents('public://foobar/Èxample-✓.txt'));
}