public function UploadFileServiceTest::testExtensionRenaming in GraphQL 8.4
Tests that the uploaded file extension is renamed to txt.
File
- tests/
src/ Kernel/ Framework/ UploadFileServiceTest.php, line 152
Class
- UploadFileServiceTest
- Tests file uploads that should be mapped to a field in a resolver.
Namespace
Drupal\Tests\graphql\Kernel\FrameworkCode
public function testExtensionRenaming() : void {
// Evil php file extension!
$uploadFile = $this
->getUploadedFile(UPLOAD_ERR_OK, 0, 'test.php');
$file_upload_response = $this->uploadService
->saveFileUpload($uploadFile, [
'uri_scheme' => 'public',
'file_directory' => 'test',
]);
$file_entity = $file_upload_response
->getFileEntity();
$this
->assertSame('public://test/test.php_.txt', $file_entity
->getFileUri());
$this
->assertFileExists($file_entity
->getFileUri());
}