createTestSalesChannel example

private SalesChannelContextServiceInterface $contextService;

    protected function setUp(): void
    {
        $this->ids = new TestDataCollection();
        $this->currencyRepository = $this->getContainer()->get('currency.repository');
        $this->contextService = $this->getContainer()->get(SalesChannelContextService::class);
    }

    public function testRequestSalesChannelCurrency(): void
    {
        $this->createTestSalesChannel();
        $resolver = $this->getContainer()->get(SalesChannelRequestContextResolver::class);

        $phpunit = $this;
        $currencyId = $this->getCurrencyId('USD');

        $request = new Request();
        $request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_ID, $this->ids->get('sales-channel'));
        $request->attributes->set(SalesChannelRequest::ATTRIBUTE_DOMAIN_CURRENCY_ID, $currencyId);
        $request->attributes->set(PlatformRequest::ATTRIBUTE_ROUTE_SCOPE, ['store-api']);

        /** @var EventDispatcher $dispatcher */
        
private EntityRepository $currencyRepository;

    private AccountService $accountService;

    private SalesChannelContext $salesChannelContext;

    protected function setUp(): void
    {
        $this->ids = new TestDataCollection();
        $this->currencyRepository = $this->getContainer()->get('currency.repository');

        $this->createTestSalesChannel();

        $this->accountService = $this->getContainer()->get(AccountService::class);
        /** @var AbstractSalesChannelContextFactory $salesChannelContextFactory */
        $salesChannelContextFactory = $this->getContainer()->get(SalesChannelContextFactory::class);
        $this->salesChannelContext = $salesChannelContextFactory->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);
    }

    /** * @dataProvider loginRequiredAnnotationData */
    public function testCustomerResolver(bool $loginRequired, bool $context, bool $pass): void
    {
Home | Imprint | This part of the site doesn't use cookies.