ImportExportHandler example


#[Package('system-settings')] class ImportExportHandlerTest extends AbstractImportExportTestCase
{
    public function testImportExportHandlerDispatchesMessage(): void
    {
        /** @var TraceableMessageBus $messageBus */
        $messageBus = $this->getContainer()->get('messenger.bus.shopware');
        $factory = $this->getContainer()->get(ImportExportFactory::class);
        $context = Context::createDefaultContext();

        $importExportHandler = new ImportExportHandler($messageBus$factory);

        $importExportService = $this->getContainer()->get(ImportExportService::class);

        $profileId = $this->getDefaultProfileId(PropertyGroupOptionDefinition::ENTITY_NAME);

        $expireDate = new \DateTimeImmutable('2099-01-01');
        $file = new UploadedFile(__DIR__ . '/../fixtures/properties.csv', 'properties.csv', 'text/csv');

        $logEntity = $importExportService->prepareImport(
            $context,
            $profileId,
            

    public function testImportExportHandlerDispatchesMessage(string $activity): void
    {
        $messageBus = new CollectingMessageBus();

        $factory = $this->createMock(ImportExportFactory::class);

        $adminSource = new AdminApiSource('userId');
        $adminSource->setIsAdmin(true);
        $context = Context::createDefaultContext($adminSource);

        $importExportHandler = new ImportExportHandler($messageBus$factory);

        $logEntity = new ImportExportLogEntity();
        $logEntity->setActivity($activity);
        $logEntity->setState(Progress::STATE_PROGRESS);
        $logEntity->setId('logId');

        $progress = new Progress($logEntity->getId()$logEntity->getState());

        $importExport = $this->createMock(ImportExport::class);
        $importExport->method('import')
            ->willReturn($progress);
        
Home | Imprint | This part of the site doesn't use cookies.