function FileSystemTest::testCopyFailureIfSelfOverwrite

Tests copy failure if self overwrite.

@legacy-covers ::copy

File

core/tests/Drupal/KernelTests/Core/File/FileSystemTest.php, line 88

Class

FileSystemTest
Tests Drupal\Core\File\FileSystem.

Namespace

Drupal\KernelTests\Core\File

Code

public function testCopyFailureIfSelfOverwrite() : void {
  $this->expectException(FileException::class);
  $this->expectExceptionMessage("'public://test.txt' could not be copied because it would overwrite itself");
  $uri = 'public://test.txt';
  touch($uri);
  $this->fileSystem
    ->copy($uri, $uri, FileExists::Replace);
}

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