$criteria =
new Criteria([$productId]);
$progress =
$this->
export(Context::
createDefaultContext(), ProductDefinition::ENTITY_NAME,
$criteria);
static::
assertTrue($progress->
isFinished());
static::
assertImportExportSucceeded($progress,
$this->
getInvalidLogContent($progress->
getInvalidRecordsLogId()));
$progress =
$this->
export(Context::
createDefaultContext(), ProductDefinition::ENTITY_NAME,
$criteria);
/** @var EntityRepository $fileRepository */
$fileRepository =
$this->
getContainer()->
get('import_export_file.repository'
);
/** @var ImportExportFileEntity|null $file */
$file =
$fileRepository->
search(new Criteria(array_filter([$this->
getLogEntity($progress->
getLogId())->
getFileId()])), Context::
createDefaultContext())->
first();
static::
assertNotNull($file);
$importExportFileEntity =
$this->
getLogEntity($progress->
getLogId())->
getFile();
static::
assertInstanceOf(ImportExportFileEntity::
class,
$importExportFileEntity);
static::
assertSame($filesystem->
fileSize($importExportFileEntity->
getPath()),
$file->
getSize());
$this->productRepository->
delete([['id' =>
$productId]], Context::
createDefaultContext());
$exportFileTmp =
(string) tempnam(sys_get_temp_dir(), ''
);
file_put_contents($exportFileTmp,
(string) $filesystem->
read($file->
getPath()));
$progress =
$this->
import(Context::
createDefaultContext(), ProductDefinition::ENTITY_NAME,
$exportFileTmp, 'test.csv', null, false, true
);