Loading core/modules/migrate/src/Plugin/migrate/process/Download.php +4 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,10 @@ public function transform($value, MigrateExecutableInterface $migrate_executable throw new MigrateException("{$e->getMessage()} ($source)"); } if (is_resource($destination_stream)) { fclose($destination_stream); } return $final_destination; } Loading core/modules/migrate/tests/src/Kernel/process/DownloadTest.php +10 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ protected function setUp(): void { * Tests a download that overwrites an existing local file. */ public function testOverwritingDownload() { // Create a pre-existing file at the destination, to test overwrite behavior. // Create a pre-existing file at the destination. $destination_uri = $this->createUri('existing_file.txt'); // Test destructive download. Loading @@ -47,7 +47,7 @@ public function testOverwritingDownload() { * Tests a download that renames the downloaded file if there's a collision. */ public function testNonDestructiveDownload() { // Create a pre-existing file at the destination, to test overwrite behavior. // Create a pre-existing file at the destination. $destination_uri = $this->createUri('another_existing_file.txt'); // Test non-destructive download. Loading @@ -60,7 +60,7 @@ public function testNonDestructiveDownload() { * Tests that an exception is thrown if the destination URI is not writable. */ public function testWriteProtectedDestination() { // Create a pre-existing file at the destination, to test overwrite behavior. // Create a pre-existing file at the destination. $destination_uri = $this->createUri('not-writable.txt'); // Make the destination non-writable. Loading Loading @@ -115,7 +115,13 @@ protected function doTransform($destination_uri, $configuration = []) { 'http://drupal.org/favicon.ico', $destination_uri, ]; return $plugin->transform($value, $executable, $row, 'foo'); // Assert that number of stream resources in use is the same before and // after the download. $initial_count = count(get_resources('stream')); $return = $plugin->transform($value, $executable, $row, 'foo'); $this->assertCount($initial_count, get_resources('stream')); return $return; } } Loading
core/modules/migrate/src/Plugin/migrate/process/Download.php +4 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,10 @@ public function transform($value, MigrateExecutableInterface $migrate_executable throw new MigrateException("{$e->getMessage()} ($source)"); } if (is_resource($destination_stream)) { fclose($destination_stream); } return $final_destination; } Loading
core/modules/migrate/tests/src/Kernel/process/DownloadTest.php +10 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ protected function setUp(): void { * Tests a download that overwrites an existing local file. */ public function testOverwritingDownload() { // Create a pre-existing file at the destination, to test overwrite behavior. // Create a pre-existing file at the destination. $destination_uri = $this->createUri('existing_file.txt'); // Test destructive download. Loading @@ -47,7 +47,7 @@ public function testOverwritingDownload() { * Tests a download that renames the downloaded file if there's a collision. */ public function testNonDestructiveDownload() { // Create a pre-existing file at the destination, to test overwrite behavior. // Create a pre-existing file at the destination. $destination_uri = $this->createUri('another_existing_file.txt'); // Test non-destructive download. Loading @@ -60,7 +60,7 @@ public function testNonDestructiveDownload() { * Tests that an exception is thrown if the destination URI is not writable. */ public function testWriteProtectedDestination() { // Create a pre-existing file at the destination, to test overwrite behavior. // Create a pre-existing file at the destination. $destination_uri = $this->createUri('not-writable.txt'); // Make the destination non-writable. Loading Loading @@ -115,7 +115,13 @@ protected function doTransform($destination_uri, $configuration = []) { 'http://drupal.org/favicon.ico', $destination_uri, ]; return $plugin->transform($value, $executable, $row, 'foo'); // Assert that number of stream resources in use is the same before and // after the download. $initial_count = count(get_resources('stream')); $return = $plugin->transform($value, $executable, $row, 'foo'); $this->assertCount($initial_count, get_resources('stream')); return $return; } }