Skip to content

Commit 9849588

Browse files
committed
B2B-2023: [AWS S3] [Integration Tests]: Investigate Test Failures in CatalogImportExport module
1 parent 683664a commit 9849588

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed

app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ public function testPrepareRowForDb()
588588
$directoryMock->expects($this->any())
589589
->method('openFile')
590590
->willReturn(new Read($pathToCsvFile, new File()));
591+
$directoryMock->expects($this->any())
592+
->method('getRelativePath')
593+
->with($pathToCsvFile)
594+
->willReturn($pathToCsvFile);
591595
$source = new Csv($pathToCsvFile, $directoryMock);
592596
$modelUnderTest->setSource($source);
593597
$modelUnderTest->validateData();

app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/CsvTest.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ protected function setUp(): void
4040

4141
public function testConstructException()
4242
{
43+
$filePath = __DIR__ . '/invalid_file';
4344
$this->expectException(\LogicException::class);
44-
$this->_directoryMock->expects($this->any())
45+
$this->_directoryMock->expects($this->once())
46+
->method('getRelativePath')
47+
->with($filePath)
48+
->willReturn($filePath);
49+
$this->_directoryMock->expects($this->once())
4550
->method('openFile')
4651
->willThrowException(new FileSystemException(__('Error message')));
47-
new Csv(__DIR__ . '/invalid_file', $this->_directoryMock);
52+
new Csv($filePath, $this->_directoryMock);
4853
}
4954

5055
public function testConstructStream()
@@ -56,9 +61,9 @@ public function testConstructStream()
5661
)->method(
5762
'openFile'
5863
)->willReturn(
59-
60-
new Read($stream, new Http())
61-
64+
65+
new Read($stream, new Http())
66+
6267
);
6368
$this->_filesystem->expects(
6469
$this->any()
@@ -82,18 +87,16 @@ public function testConstructStream()
8287
*/
8388
public function testOptionalArgs($delimiter, $enclosure, $expectedColumns)
8489
{
85-
$this->_directoryMock->expects(
86-
$this->any()
87-
)->method(
88-
'openFile'
89-
)->willReturn(
90-
new Read(
91-
__DIR__ . '/_files/test.csv',
92-
new File()
93-
)
94-
);
90+
$filePath = __DIR__ . '/_files/test.csv';
91+
$this->_directoryMock->expects($this->once())
92+
->method('getRelativePath')
93+
->with($filePath)
94+
->willReturn($filePath);
95+
$this->_directoryMock->expects($this->any())
96+
->method('openFile')
97+
->willReturn(new Read($filePath, new File()));
9598
$model = new Csv(
96-
__DIR__ . '/_files/test.csv',
99+
$filePath,
97100
$this->_directoryMock,
98101
$delimiter,
99102
$enclosure
@@ -117,20 +120,15 @@ public function testRewind()
117120
{
118121
$this->expectException(\InvalidArgumentException::class);
119122
$this->expectExceptionMessage('wrongColumnsNumber');
120-
$this->_directoryMock->expects(
121-
$this->any()
122-
)->method(
123-
'openFile'
124-
)->willReturn(
125-
new Read(
126-
__DIR__ . '/_files/test.csv',
127-
new File()
128-
)
129-
);
130-
$model = new Csv(
131-
__DIR__ . '/_files/test.csv',
132-
$this->_directoryMock
133-
);
123+
$filePath = __DIR__ . '/_files/test.csv';
124+
$this->_directoryMock->expects($this->once())
125+
->method('getRelativePath')
126+
->with($filePath)
127+
->willReturn($filePath);
128+
$this->_directoryMock->expects($this->any())
129+
->method('openFile')
130+
->willReturn(new Read($filePath, new File()));
131+
$model = new Csv($filePath, $this->_directoryMock);
134132
$this->assertSame(-1, $model->key());
135133
$model->next();
136134
$this->assertSame(0, $model->key());

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ImportWithNotExistImagesTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Magento\Framework\MessageQueue\MessageEncoder;
1919
use Magento\Framework\ObjectManagerInterface;
2020
use Magento\ImportExport\Model\Export\Consumer;
21-
use Magento\ImportExport\Model\Import;
2221
use Magento\ImportExport\Model\Import as ImportModel;
2322
use Magento\ImportExport\Model\Import\Source\Csv as CsvSource;
2423
use Magento\ImportExport\Model\Import\Source\CsvFactory;
@@ -134,7 +133,7 @@ public function testImportWithUnexistingImages(): void
134133
$this->import->setParameters([
135134
'entity' => Product::ENTITY,
136135
'behavior' => ImportModel::BEHAVIOR_ADD_UPDATE,
137-
Import::FIELD_NAME_IMG_FILE_DIR => $mediaDirectory->getAbsolutePath('import')
136+
ImportModel::FIELD_NAME_IMG_FILE_DIR => $mediaDirectory->getAbsolutePath('import')
138137
]);
139138
$this->assertImportErrors();
140139
$this->assertProductImages('/m/a/magento_image.jpg', 'simple');

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/media_import_image.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
$dirPath = $mediaDirectory->getAbsolutePath('import/m/a');
1515
$driver = $mediaDirectory->getDriver();
1616
$driver->createDirectory($dirPath);
17-
$driver->filePutContents($dirPath . '/magento_image.jpg', file_get_contents(__DIR__ . '/../../../../../Magento/Catalog/_files/magento_image.jpg'));
17+
$driver->filePutContents(
18+
$dirPath . '/magento_image.jpg',
19+
file_get_contents(__DIR__ . '/../../../../../Magento/Catalog/_files/magento_image.jpg')
20+
);

0 commit comments

Comments
 (0)