function LegacyFileUploadHandlerTest::testThrow
Same name in other branches
- 11.x core/modules/file/tests/src/Kernel/Upload/LegacyFileUploadHandlerTest.php \Drupal\Tests\file\Kernel\Upload\LegacyFileUploadHandlerTest::testThrow()
@covers ::handleFileUpload
File
-
core/
modules/ file/ tests/ src/ Kernel/ Upload/ LegacyFileUploadHandlerTest.php, line 28
Class
- LegacyFileUploadHandlerTest
- Provides tests for legacy file upload handler code.
Namespace
Drupal\Tests\file\Kernel\UploadCode
public function testThrow() : void {
$fileUploadHandler = $this->container
->get('file.upload_handler');
$uploadedFile = $this->createMock(UploadedFileInterface::class);
$uploadedFile->expects($this->once())
->method('isValid')
->willReturn(FALSE);
$this->expectDeprecation('Calling Drupal\\file\\Upload\\FileUploadHandler::handleFileUpload() with the $throw argument as TRUE is deprecated in drupal:10.3.0 and will be removed in drupal:11.0.0. Use \\Drupal\\file\\Upload\\FileUploadResult::getViolations() instead. See https://www.drupal.org/node/3375456');
$this->expectException(FileException::class);
$result = $fileUploadHandler->handleFileUpload(uploadedFile: $uploadedFile, throw: TRUE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.