function FileCopyTest::testNonWritableDestination
Tests that non-writable destination throw an exception.
@covers ::transform
      
    
File
- 
              core/modules/ migrate/ tests/ src/ Kernel/ process/ FileCopyTest.php, line 177 
Class
- FileCopyTest
- Tests the file_copy process plugin.
Namespace
Drupal\Tests\migrate\Kernel\processCode
public function testNonWritableDestination() : void {
  $source = $this->createUri('file.txt', NULL, 'temporary');
  // Create the parent location.
  $this->createDirectory('public://dir');
  // Copy the file under public://dir/subdir1/.
  $this->doTransform($source, 'public://dir/subdir1/file.txt');
  // Check that 'subdir1' was created and the file was successfully migrated.
  $this->assertFileExists('public://dir/subdir1/file.txt');
  // Remove all permissions from public://dir to trigger a failure when
  // trying to create a subdirectory 'subdir2' inside public://dir.
  $this->fileSystem
    ->chmod('public://dir', 0);
  // Check that the proper exception is raised.
  $this->expectException(MigrateException::class);
  $this->expectExceptionMessage("Could not create or write to directory 'public://dir/subdir2'");
  $this->doTransform($source, 'public://dir/subdir2/file.txt');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
