function FileCopyTest::testSuccessfulCopies
Same name in other branches
- 8.9.x core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php \Drupal\Tests\migrate\Kernel\process\FileCopyTest::testSuccessfulCopies()
- 10 core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php \Drupal\Tests\migrate\Kernel\process\FileCopyTest::testSuccessfulCopies()
- 11.x core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php \Drupal\Tests\migrate\Kernel\process\FileCopyTest::testSuccessfulCopies()
Tests successful imports/copies.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ process/ FileCopyTest.php, line 47
Class
- FileCopyTest
- Tests the file_copy process plugin.
Namespace
Drupal\Tests\migrate\Kernel\processCode
public function testSuccessfulCopies() {
$file = $this->createUri(NULL, NULL, 'temporary');
$file_absolute = $this->fileSystem
->realpath($file);
$data_sets = [
// Test a local to local copy.
[
$this->root . '/core/tests/fixtures/files/image-test.jpg',
'public://file1.jpg',
],
// Test a temporary file using an absolute path.
[
$file_absolute,
'temporary://test.jpg',
],
// Test a temporary file using a relative path.
[
$file_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);
$this->assertFileExists($destination_path);
// Make sure we didn't accidentally do a move.
$this->assertFileExists($source_path);
$this->assertSame($actual_destination, $destination_path, 'The import returned the copied filename.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.