You are here

public function DownloadTest::testNonDestructiveDownload in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/process/DownloadTest.php \Drupal\Tests\migrate\Kernel\process\DownloadTest::testNonDestructiveDownload()

Tests a download that renames the downloaded file if there's a collision.

File

core/modules/migrate/tests/src/Kernel/process/DownloadTest.php, line 49

Class

DownloadTest
Tests the download process plugin.

Namespace

Drupal\Tests\migrate\Kernel\process

Code

public function testNonDestructiveDownload() {

  // Create a pre-existing file at the destination, to test overwrite behavior.
  $destination_uri = $this
    ->createUri('another_existing_file.txt');

  // Test non-destructive download.
  $actual_destination = $this
    ->doTransform($destination_uri, [
    'file_exists' => 'rename',
  ]);
  $this
    ->assertSame('public://another_existing_file_0.txt', $actual_destination, 'Import returned a renamed destination');
  $this
    ->assertFileExists($actual_destination);
}