function FileCopyTest::testSuccessfulMoves
Same name in other branches
- 9 core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php \Drupal\Tests\migrate\Kernel\process\FileCopyTest::testSuccessfulMoves()
- 8.9.x core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php \Drupal\Tests\migrate\Kernel\process\FileCopyTest::testSuccessfulMoves()
- 11.x core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php \Drupal\Tests\migrate\Kernel\process\FileCopyTest::testSuccessfulMoves()
Tests successful moves.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ process/ FileCopyTest.php, line 130
Class
- FileCopyTest
- Tests the file_copy process plugin.
Namespace
Drupal\Tests\migrate\Kernel\processCode
public function testSuccessfulMoves() : void {
$file_1 = $this->createUri(NULL, NULL, 'temporary');
$file_1_absolute = $this->fileSystem
->realpath($file_1);
$file_2 = $this->createUri(NULL, NULL, 'temporary');
$file_2_absolute = $this->fileSystem
->realpath($file_2);
$local_file = $this->createUri(NULL, NULL, 'public');
$data_sets = [
// Test a local to local copy.
[
$local_file,
'public://file1.jpg',
],
// Test a temporary file using an absolute path.
[
$file_1_absolute,
'temporary://test.jpg',
],
// Test a temporary file using a relative path.
[
$file_2_absolute,
'temporary://core/tests/fixtures/files/test.jpg',
],
];
foreach ($data_sets as $data) {
[
$source_path,
$destination_path,
] = $data;
$actual_destination = $this->doTransform($source_path, $destination_path, [
'move' => TRUE,
]);
$this->assertFileExists($destination_path);
$this->assertFileDoesNotExist($source_path);
$this->assertSame($actual_destination, $destination_path, 'The importer returned the moved filename.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.