Skip to content

Commit f44b983

Browse files
committed
B2B-2027: [AWS S3] [Integration Tests]: Investigate Test Failures in Customer module
1 parent 9ff22de commit f44b983

File tree

1 file changed

+16
-4
lines changed
  • dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/Form

1 file changed

+16
-4
lines changed

dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testProcessCustomerAddressValue()
7676
$this->mediaDirectory->delete('customer_address');
7777
$this->mediaDirectory->create($this->mediaDirectory->getRelativePath('customer_address/tmp/'));
7878
$tmpFilePath = $this->mediaDirectory->getAbsolutePath('customer_address/tmp/' . $this->fileName);
79-
copy($this->imageFixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFilePath);
79+
$this->copyFile($this->imageFixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFilePath);
8080

8181
$imageFile = [
8282
'name' => $this->fileName,
@@ -106,7 +106,7 @@ public function testProcessCustomerAddressValue()
106106
$processCustomerAddressValueMethod->setAccessible(true);
107107
$actual = $processCustomerAddressValueMethod->invoke($image, $imageFile);
108108
$this->assertEquals($this->expectedFileName, $actual);
109-
$this->assertFileExists($expectedPath);
109+
$this->assertTrue($this->mediaDirectory->isExist($expectedPath));
110110
$this->assertFileDoesNotExist($tmpFilePath);
111111
}
112112

@@ -122,7 +122,7 @@ public function testProcessCustomerValue()
122122
$this->mediaDirectory->delete('customer');
123123
$this->mediaDirectory->create($this->mediaDirectory->getRelativePath('customer/tmp/'));
124124
$tmpFilePath = $this->mediaDirectory->getAbsolutePath('customer/tmp/' . $this->fileName);
125-
copy($this->imageFixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFilePath);
125+
$this->copyFile($this->imageFixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFilePath);
126126

127127
$imageFile = [
128128
'name' => $this->fileName,
@@ -170,7 +170,7 @@ public function testProcessCustomerInvalidValue()
170170
$this->mediaDirectory->delete('customer');
171171
$this->mediaDirectory->create($this->mediaDirectory->getRelativePath('customer/tmp/'));
172172
$tmpFilePath = $this->mediaDirectory->getAbsolutePath('customer/tmp/' . $this->fileName);
173-
copy($this->imageFixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFilePath);
173+
$this->copyFile($this->imageFixtureDir . DIRECTORY_SEPARATOR . $this->fileName, $tmpFilePath);
174174

175175
$imageFile = [
176176
'name' => $this->fileName,
@@ -214,4 +214,16 @@ public static function tearDownAfterClass(): void
214214
$mediaDirectory->delete('customer');
215215
$mediaDirectory->delete('customer_address');
216216
}
217+
218+
/**
219+
* @param string $source
220+
* @param string $destination
221+
* @throws FileSystemException
222+
*/
223+
private function copyFile(string $source, string $destination)
224+
{
225+
$driver = $this->mediaDirectory->getDriver();
226+
$driver->createDirectory(dirname($destination));
227+
$driver->filePutContents($destination, file_get_contents($source));
228+
}
217229
}

0 commit comments

Comments
 (0)