function LegacyFileUploadHandlerTest::testThrow

Same name and namespace in other branches
  1. 10 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 26

Class

LegacyFileUploadHandlerTest
Provides tests for legacy file upload handler code.

Namespace

Drupal\Tests\file\Kernel\Upload

Code

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.