Skip to content

Commit 4a28d98

Browse files
committed
Merge branch 'B2B-2100-1' of https://github.com/magento-arcticfoxes/magento2ce into B2B-2140
2 parents 0a95fc6 + a1e0486 commit 4a28d98

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

app/code/Magento/Backend/Test/Mftf/Helper/CurlHelpers.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Backend\Test\Mftf\Helper;
99

10+
use Magento\Framework\Filesystem\Driver\File;
1011
use Magento\FunctionalTestingFramework\Helper\Helper;
1112

1213
/**
@@ -113,6 +114,28 @@ public function assertCurlResponseHeadersContainsString(
113114
$this->assertStringContainsString($expectedString, $curlResponse);
114115
}
115116

117+
/**
118+
* Saves file to provided $targetPath with content retrieved from file by $url
119+
*
120+
* @param string $url
121+
* @param string $targetPath File path where to save downloaded data from $url
122+
* @param string $cookieName
123+
* @param string|null $postBody
124+
* @throws \Exception
125+
*/
126+
public function downloadFile(
127+
string $url,
128+
string $targetPath,
129+
string $cookieName = 'admin',
130+
?string $postBody = null
131+
): void {
132+
$cookie = $this->getCookie($cookieName);
133+
$content = $this->getCurlResponse($url, $cookie, $postBody);
134+
$targetPath = (substr($targetPath, 0, 1) === '/') ? $targetPath : MAGENTO_BP . '/' . $targetPath;
135+
$driver = new File();
136+
$driver->filePutContents($targetPath, $content);
137+
}
138+
116139
/**
117140
* Sends a curl request with the provided URL & cookie. Returns the response
118141
*

0 commit comments

Comments
 (0)