function FileUploadSanitizeNameEventTest::testSetFilenameException

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php \Drupal\Tests\Core\File\FileUploadSanitizeNameEventTest::testSetFilenameException()
  2. 11.x core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php \Drupal\Tests\Core\File\FileUploadSanitizeNameEventTest::testSetFilenameException()

@covers ::setFilename

File

core/tests/Drupal/Tests/Core/File/FileUploadSanitizeNameEventTest.php, line 34

Class

FileUploadSanitizeNameEventTest
FileUploadSanitizeNameEvent tests.

Namespace

Drupal\Tests\Core\File

Code

public function testSetFilenameException() : void {
    $event = new FileUploadSanitizeNameEvent('foo.txt', '');
    $this->assertSame('foo.txt', $event->getFilename());
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('$filename must be a filename with no path information, "bar/foo.html" provided');
    $event->setFilename('bar/foo.html');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.