@@ -49,7 +49,7 @@ class DownloadTest extends AbstractBackendController
49
49
/**
50
50
* @var string
51
51
*/
52
- private $ sourceFilePath ;
52
+ private string $ sourceFilePath ;
53
53
54
54
/**
55
55
* @inheritdoc
@@ -58,14 +58,15 @@ protected function setUp(): void
58
58
{
59
59
parent ::setUp ();
60
60
61
- $ this ->fileSystem = $ this ->_objectManager ->get (Filesystem::class);
62
- $ auth = $ this ->_objectManager ->get (Auth::class);
63
- $ auth ->getAuthStorage ()->setIsFirstPageAfterLogin (false );
61
+ $ this ->auth = $ this ->_objectManager ->get (Auth::class);
62
+ $ this ->auth ->getAuthStorage ()->setIsFirstPageAfterLogin (false );
64
63
$ this ->backendUrl = $ this ->_objectManager ->get (BackendUrl::class);
65
64
$ this ->backendUrl ->turnOnSecretKey ();
66
65
$ this ->sourceFilePath = __DIR__ . '/../../Import/_files ' . DIRECTORY_SEPARATOR . $ this ->fileName ;
66
+
67
+ $ this ->fileSystem = $ this ->_objectManager ->get (Filesystem::class);
67
68
//Refers to tests 'var' directory
68
- $ this ->varDirectory = $ this ->fileSystem ->getDirectoryRead (DirectoryList::VAR_DIR );
69
+ $ this ->varDirectory = $ this ->fileSystem ->getDirectoryWrite (DirectoryList::VAR_IMPORT_EXPORT );
69
70
}
70
71
71
72
/**
@@ -121,12 +122,16 @@ public function testExecute($file): void
121
122
*
122
123
* @param $destinationFilePath
123
124
* @return void
125
+ * @throws \Magento\Framework\Exception\FileSystemException
124
126
*/
125
127
private function copyFile ($ destinationFilePath ): void
126
128
{
127
- //Refers to application root directory
128
- $ rootDirectory = $ this ->fileSystem ->getDirectoryWrite (DirectoryList::ROOT );
129
- $ rootDirectory ->copyFile ($ this ->sourceFilePath , $ this ->varDirectory ->getAbsolutePath ($ destinationFilePath ));
129
+ $ driver = $ this ->varDirectory ->getDriver ();
130
+
131
+ $ driver ->filePutContents (
132
+ $ this ->varDirectory ->getAbsolutePath ($ destinationFilePath ),
133
+ file_get_contents ($ this ->sourceFilePath )
134
+ );
130
135
}
131
136
132
137
/**
@@ -159,7 +164,7 @@ public static function tearDownAfterClass(): void
159
164
{
160
165
$ filesystem = Bootstrap::getObjectManager ()->get (Filesystem::class);
161
166
/** @var WriteInterface $directory */
162
- $ directory = $ filesystem ->getDirectoryWrite (DirectoryList::VAR_DIR );
167
+ $ directory = $ filesystem ->getDirectoryWrite (DirectoryList::VAR_IMPORT_EXPORT );
163
168
if ($ directory ->isExist ('export ' )) {
164
169
$ directory ->delete ('export ' );
165
170
}
0 commit comments