getFileId example

$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);

        
if ($tmpFile) {
            unlink($tmpFile);
        }

        foreach ($partFiles as $p) {
            $this->filesystem->delete($p);
        }

        $progress->setState(Progress::STATE_SUCCEEDED);
        $this->importExportService->saveProgress($progress);

        $fileId = $logEntity->getFileId();
        if ($fileId === null) {
            throw ImportExportException::processingError('log does not have a file id');
        }

        $this->fileService->updateFile(
            Context::createDefaultContext(),
            $fileId,
            ['size' => $this->filesystem->fileSize($target)]
        );

        return $progress;
    }
foreach ($data as $expect) {
            $id = $expect['id'];
            $result = $this->logRepository->search(new Criteria([$id])$this->context);
            /** @var ImportExportLogEntity $ImportExportLog */
            $ImportExportLog = $result->get($id);
            static::assertCount(1, $result);
            static::assertSame($expect['activity']$ImportExportLog->getActivity());
            static::assertSame($expect['state']$ImportExportLog->getState());
            static::assertSame($expect['userId']$ImportExportLog->getUserId());
            static::assertSame($expect['profileId']$ImportExportLog->getProfileId());
            static::assertSame($expect['fileId']$ImportExportLog->getFileId());
            static::assertSame($expect['username']$ImportExportLog->getUsername());
            static::assertSame($expect['profileName']$ImportExportLog->getProfileName());
        }
    }

    public function testImportExportLogReadNoResult(): void
    {
        $num = 3;
        $data = $this->prepareImportExportLogTestData($num);

        $this->logRepository->create(array_values($data)$this->context);

        
Home | Imprint | This part of the site doesn't use cookies.