Skip to content

Commit

Permalink
Merge pull request #156 from magento-arcticfoxes/B2B-2018
Browse files Browse the repository at this point in the history
B2B-2018: [AWS S3] [Integration Tests]: Investigate Test Failures in InventoryImportExport module
  • Loading branch information
danmooney2 authored Dec 6, 2021
2 parents 6f57e70 + 009d84e commit d1c2d3c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
40 changes: 21 additions & 19 deletions InventoryImportExport/Test/Integration/Model/Export/SourcesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Magento\InventoryImportExport\Test\Integration\Model\Export;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\ImportExport\Model\Export;
use Magento\ImportExport\Model\Export\Adapter\Csv;
use Magento\InventoryImportExport\Model\Export\Sources;
Expand All @@ -25,25 +27,27 @@ class SourcesTest extends TestCase
*/
private $exportFilePath;

/**
* @var Filesystem\Directory\WriteInterface
*/
private $directory;

protected function setUp(): void
{
$sandboxDir = Bootstrap::getInstance()->getBootstrap()->getApplication()->getTempDir();
$this->exportFilePath = implode(DIRECTORY_SEPARATOR, [
$sandboxDir,
'var',
uniqid('test-export_', false) . '.csv'
]);
$objectManager = Bootstrap::getObjectManager();
$this->exportFilePath = uniqid('test-export_', false) . '.csv';

$this->exporter = Bootstrap::getObjectManager()->create(Sources::class);
$this->exporter->setWriter(Bootstrap::getObjectManager()->create(
$this->directory = $objectManager->get(Filesystem::class)->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
$this->exporter = $objectManager->create(Sources::class);
$this->exporter->setWriter($objectManager->create(
Csv::class,
['destination' => $this->exportFilePath]
));
}

protected function tearDown(): void
{
unlink($this->exportFilePath);
$this->directory->delete($this->exportFilePath);
}

/**
Expand All @@ -64,11 +68,9 @@ public function testExportWithoutAnyFiltering()
FILE_IGNORE_NEW_LINES
);

foreach ($exportFullLines as $line) {
$this->assertStringContainsString(
$line,
file_get_contents($this->exportFilePath)
);
$exportContent = $this->directory->readFile($this->exportFilePath);
foreach ($exportFullLines as $expectedLine) {
$this->assertStringContainsString($expectedLine, $exportContent);
}
}

Expand All @@ -91,7 +93,7 @@ public function testExportWithSkuFilter()

$this->assertEquals(
file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '_files', 'export_filtered_by_sku.csv'])),
file_get_contents($this->exportFilePath)
$this->directory->readFile($this->exportFilePath)
);
}

Expand All @@ -113,7 +115,7 @@ public function testExportWithSkuFilterByLikeQuery()

$this->assertEquals(
file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '_files', 'export_filtered_by_sku.csv'])),
file_get_contents($this->exportFilePath)
$this->directory->readFile($this->exportFilePath)
);
}

Expand All @@ -135,7 +137,7 @@ public function testExportWithSourceFilter()

$this->assertEquals(
file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '_files', 'export_filtered_by_source.csv'])),
file_get_contents($this->exportFilePath)
$this->directory->readFile($this->exportFilePath)
);
}

Expand All @@ -160,7 +162,7 @@ public function testExportWithWebsiteFilter(int $websiteId, string $expectedOutp

$this->assertEquals(
file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '_files', $expectedOutput])),
file_get_contents($this->exportFilePath)
$this->directory->readFile($this->exportFilePath)
);
}

Expand Down Expand Up @@ -190,7 +192,7 @@ public function testExportFilteredWithoutStatusColumn()
'_files',
'export_filtered_without_status_column.csv'
])),
file_get_contents($this->exportFilePath)
$this->directory->readFile($this->exportFilePath)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public function getProductExporter(): ProductExporter
uniqid('test-export_', false) . '.csv'
]
);
$writer = $this->objectManager->create(ExportCsv::class, ['destination' => $this->exportFilePath]);
$writer = $this->objectManager->create(ExportCsv::class, [
'destination' => $this->exportFilePath,
'destinationDirectoryCode' => DirectoryList::ROOT
]);
$productExporter = $this->objectManager->get(ProductExporter::class);
$productExporter->setWriter($writer);
$productExporter->setParameters([]);
Expand Down

0 comments on commit d1c2d3c

Please sign in to comment.