FileSaver example

->willReturn($searchResult);

        $repositoryMock->expects(static::once())
            ->method('update')
            ->willThrowException(new \Exception());

        /** @var list<string> $allowed */
        $allowed = $this->getContainer()->getParameter('shopware.filesystem.allowed_extensions');
        /** @var list<string> $allowedPrivate */
        $allowedPrivate = $this->getContainer()->getParameter('shopware.filesystem.private_allowed_extensions');

        $fileSaverWithFailingRepository = new FileSaver(
            $repositoryMock,
            $this->getContainer()->get('shopware.filesystem.public'),
            $this->getContainer()->get('shopware.filesystem.private'),
            $this->getContainer()->get(UrlGeneratorInterface::class),
            $this->getContainer()->get(ThumbnailService::class),
            $this->getContainer()->get(MetadataLoader::class),
            $this->getContainer()->get(TypeDetector::class),
            $this->getContainer()->get('messenger.bus.shopware'),
            $this->getContainer()->get('event_dispatcher'),
            $allowed,
            $allowedPrivate
        );

        $this->mediaRepository = $this->createMock(EntityRepository::class);
        $filesystemPublic = $this->createMock(FilesystemOperator::class);
        $urlGenerator = $this->createMock(UrlGeneratorInterface::class);
        $thumbnailService = $this->createMock(ThumbnailService::class);
        $this->messageBus = new CollectingMessageBus();
        $metadataLoader = $this->createMock(MetadataLoader::class);
        $typeDetector = $this->createMock(TypeDetector::class);
        $filesystemPrivate = $this->createMock(FilesystemOperator::class);
        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);

        $this->fileSaver = new FileSaver(
            $this->mediaRepository,
            $filesystemPublic,
            $filesystemPrivate,
            $urlGenerator,
            $thumbnailService,
            $metadataLoader,
            $typeDetector,
            $this->messageBus,
            $eventDispatcher,
            ['png'],
            ['png']
        );
Home | Imprint | This part of the site doesn't use cookies.