File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
app/code/Magento/Backend/Test/Mftf/Helper Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \Backend \Test \Mftf \Helper ;
9
9
10
+ use Magento \Framework \Filesystem \Driver \File ;
10
11
use Magento \FunctionalTestingFramework \Helper \Helper ;
11
12
12
13
/**
@@ -113,6 +114,28 @@ public function assertCurlResponseHeadersContainsString(
113
114
$ this ->assertStringContainsString ($ expectedString , $ curlResponse );
114
115
}
115
116
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
+
116
139
/**
117
140
* Sends a curl request with the provided URL & cookie. Returns the response
118
141
*
You can’t perform that action at this time.
0 commit comments