AppRegistrationService example

/** * @param (HandshakeFactory&MockObject)|null $handshakeFactory * @param (EntityRepository&MockObject)|null $appRepository * @param (ShopIdProvider&MockObject)|null $shopIdProvider */
    private function createAppRegistrationService(
        ?HandshakeFactory $handshakeFactory = null,
        ?Client $httpClient = null,
        ?EntityRepository $appRepository = null,
        ?ShopIdProvider $shopIdProvider = null,
    ): AppRegistrationService {
        return new AppRegistrationService(
            $handshakeFactory ?? $this->createMock(HandshakeFactory::class),
            $httpClient ?? new Client(),
            $appRepository ?? $this->createMock(EntityRepository::class),
            'https://shopware.swag',
            $shopIdProvider ?? $this->createMock(ShopIdProvider::class),
            '6.5.2.0'
        );
    }

    /** * @param array<Response|RequestException> $responses */
$shopIdProviderMock->expects(static::once())
            ->method('getShopId')
            ->willReturn($shopId);

        $handshakeFactory = new HandshakeFactory(
            $this->shopUrl,
            $shopIdProviderMock,
            $this->getContainer()->get(StoreClient::class),
            Kernel::SHOPWARE_FALLBACK_VERSION
        );

        $registrator = new AppRegistrationService(
            $handshakeFactory,
            $this->getContainer()->get('shopware.app_system.guzzle'),
            $this->getContainer()->get('app.repository'),
            $this->shopUrl,
            $this->getContainer()->get(ShopIdProvider::class),
            Kernel::SHOPWARE_FALLBACK_VERSION
        );

        static::expectException(AppRegistrationException::class);
        $registrator->registerApp($manifest$id$secretAccessKey, Context::createDefaultContext());
    }

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