function FileSaveUploadTest::testFileSaveUploadEmptyExtensions
Same name in other branches
- 10 core/modules/file/tests/src/Kernel/FileSaveUploadTest.php \Drupal\Tests\file\Kernel\FileSaveUploadTest::testFileSaveUploadEmptyExtensions()
Tests file_save_upload() with empty extensions.
File
-
core/
modules/ file/ tests/ src/ Kernel/ FileSaveUploadTest.php, line 63
Class
- FileSaveUploadTest
- Tests file_save_upload().
Namespace
Drupal\Tests\file\KernelCode
public function testFileSaveUploadEmptyExtensions() : void {
// Allow all extensions.
$validators = [
'FileExtension' => [],
];
$files = file_save_upload('file', $validators);
$this->assertCount(1, $files);
$file = $files[0];
// @todo work out why move_uploaded_file() is failing.
$this->assertFalse($file);
$messages = \Drupal::messenger()->messagesByType(MessengerInterface::TYPE_ERROR);
$this->assertNotEmpty($messages);
$this->assertEquals('File upload error. Could not move uploaded file.', $messages[0]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.