SalesChannelCollection example

public function testSendMailSuccess(): void
    {
        $salesChannelId = Uuid::randomHex();

        $salesChannel = new SalesChannelEntity();
        $salesChannel->setId($salesChannelId);
        $context = Context::createDefaultContext();

        $salesChannelResult = new EntitySearchResult(
            'sales_channel',
            1,
            new SalesChannelCollection([$salesChannel]),
            null,
            new Criteria(),
            $context
        );

        $this->salesChannelRepository->expects(static::once())->method('search')->willReturn($salesChannelResult);

        $data = [
            'recipients' => [],
            'senderName' => 'me',
            'senderEmail' => 'me@shopware.com',
            
#[Route(path: '/api/_action/seo-url/create-custom-url', name: 'api.seo-url.create', methods: ['POST'])]     public function createCustomSeoUrls(RequestDataBag $dataBag, Context $context): Response
    {
        /** @var ParameterBag $dataBag */
        $dataBag = $dataBag->get('urls');
        $urls = $dataBag->all();

        /** @var SeoUrlValidationFactory $validatorBuilder */
        $validatorBuilder = $this->seoUrlValidator;

        $validation = $validatorBuilder->buildValidation($context, null);
        $salesChannels = new SalesChannelCollection();

        $salesChannelIds = array_column($urls, 'salesChannelId');

        if (!empty($salesChannelIds)) {
            $salesChannels = $this->salesChannelRepository->search(new Criteria($salesChannelIds)$context)->getEntities();
        }

        $writeData = [];

        foreach ($urls as $seoUrlData) {
            $id = $seoUrlData['salesChannelId'] ?? null;

            
 void {
        if ($exceptionMessage !== null) {
            static::expectExceptionMessage($exceptionMessage);
        }

        $currencyRepository = new StaticEntityRepository([new CurrencyCollection($entitySearchResult[CurrencyDefinition::ENTITY_NAME] ?? [])]);
        $customerGroupRepository = new StaticEntityRepository([new CustomerGroupCollection($entitySearchResult[CustomerGroupDefinition::ENTITY_NAME] ?? [])]);
        $countryRepository = new StaticEntityRepository([new CountryCollection($entitySearchResult[CountryDefinition::ENTITY_NAME] ?? [])]);
        $taxRepository = new StaticEntityRepository([new TaxCollection($entitySearchResult[TaxDefinition::ENTITY_NAME] ?? [])]);
        $paymentMethodRepository = new StaticEntityRepository([new PaymentMethodCollection($entitySearchResult[PaymentMethodDefinition::ENTITY_NAME] ?? [])]);
        $shippingMethodRepository = new StaticEntityRepository([new ShippingMethodCollection($entitySearchResult[ShippingMethodDefinition::ENTITY_NAME] ?? [])]);
        $salesChannelRepository = new StaticEntityRepository([new SalesChannelCollection($entitySearchResult[SalesChannelDefinition::ENTITY_NAME] ?? [])]);
        $countryStateRepository = new StaticEntityRepository([new CountryStateCollection($entitySearchResult[CountryStateDefinition::ENTITY_NAME] ?? [])]);
        $currencyCountryRepository = new StaticEntityRepository([new CurrencyCountryRoundingCollection($entitySearchResult[CurrencyCountryRoundingDefinition::ENTITY_NAME] ?? [])]);

        $connection = $this->createMock(Connection::class);
        $connection->expects(static::once())->method('fetchAssociative')->willReturn($fetchDataResult);

        if ($fetchDataResult === false) {
            $connection->expects(static::never())->method('createQueryBuilder');
        }

        if ($fetchParentLanguageResult !== false) {
            
new UserCollection([]),
        ]new UserDefinition());

        /** @var StaticEntityRepository<UserRecoveryCollection> $recoveryRepository */
        $recoveryRepository = new StaticEntityRepository([
            new UserRecoveryCollection([$recoveryEntity]),
            new UserRecoveryCollection([$recoveryEntity]),
        ]new UserRecoveryDefinition());

        /** @var StaticEntityRepository<SalesChannelCollection> $salesChannelRepository */
        $salesChannelRepository = new StaticEntityRepository([
            new SalesChannelCollection([]),
        ]new SalesChannelDefinition());

        $this->dispatcher
            ->expects(static::never())
            ->method('dispatch');

        $service = new UserRecoveryService(
            $recoveryRepository,
            $userRepository,
            $this->router,
            $this->dispatcher,
            
$themeId = Uuid::randomHex();

        $this->themeRepositoryMock->method('search')->willReturn(
            new EntitySearchResult(
                'theme',
                1,
                new ThemeCollection(
                    [
                        (new ThemeEntity())->assign(
                            [
                                '_uniqueIdentifier' => 'no',
                                'salesChannels' => new SalesChannelCollection(),
                            ]
                        ),
                    ]
                ),
                null,
                new Criteria(),
                $this->context
            )
        );

        static::expectException(InvalidThemeException::class);
        
$this->connection->method('fetchAllKeyValue')->willReturn(
            [
                '' => '{{ product.translated.name }}/{{ product.productNumber }}',
            ]
        );

        $seoUrlUpdater = $this->createSeoUrlUpdater(
            [
                new LanguageCollection([]),
            ],
            [
                new SalesChannelCollection([]),
            ],
            [
                new ProductPageSeoUrlRoute(new ProductDefinition()),
            ]
        );

        $this->seoUrlPersister->expects(static::never())->method('updateSeoUrls');

        $seoUrlUpdater->update('frontend.detail.page', []);
    }

    


    public function getDefaultPaymentMethods(): PaymentMethodCollection
    {
        return new PaymentMethodCollection(
            $this->fmap(fn (CustomerEntity $customer) => $customer->getDefaultPaymentMethod())
        );
    }

    public function getSalesChannels(): SalesChannelCollection
    {
        return new SalesChannelCollection(
            $this->fmap(fn (CustomerEntity $customer) => $customer->getSalesChannel())
        );
    }

    public function getLastPaymentMethods(): PaymentMethodCollection
    {
        return new PaymentMethodCollection(
            $this->fmap(fn (CustomerEntity $customer) => $customer->getLastPaymentMethod())
        );
    }

    


    public function getCurrencies(): CurrencyCollection
    {
        return new CurrencyCollection(
            $this->fmap(fn (OrderEntity $order) => $order->getCurrency())
        );
    }

    public function getSalesChannels(): SalesChannelCollection
    {
        return new SalesChannelCollection(
            $this->fmap(fn (OrderEntity $order) => $order->getSalesChannel())
        );
    }

    public function getBillingAddress(): OrderAddressCollection
    {
        return new OrderAddressCollection(
            $this->fmap(fn (OrderEntity $order) => $order->getAddresses())
        );
    }

    
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\System\SalesChannel\SalesChannelCollection;

/** * @extends EntityCollection<SalesChannelTypeEntity> */
#[Package('buyers-experience')] class SalesChannelTypeCollection extends EntityCollection
{
    public function getSalesChannels(): SalesChannelCollection
    {
        return new SalesChannelCollection(
            $this->fmap(fn (SalesChannelTypeEntity $salesChannel) => $salesChannel->getSalesChannels())
        );
    }

    public function getApiAlias(): string
    {
        return 'sales_channel_type_collection';
    }

    protected function getExpectedClass(): string
    {
        

    public function testThemeProviderThrowsOnGetDecorated(): void
    {
        $themeProvider = new DatabaseAvailableThemeProvider(new StaticEntityRepository([]));

        static::expectException(DecorationPatternException::class);
        $themeProvider->getDecorated();
    }

    public function testLoadThrowsExceptionInNextMajorWhenCalledWithOnlyOneParameter(): void
    {
        $themeProvider = new DatabaseAvailableThemeProvider(new StaticEntityRepository([new SalesChannelCollection()]));

        static::expectException(\RuntimeException::class);
        $themeProvider->load(Context::createDefaultContext());
    }

    /** * @DisabledFeatures(features={"v6.6.0.0"}) */
    public function testLoadCanStillBeCalledWithOneParameter(): void
    {
        $themeProvider = new DatabaseAvailableThemeProvider(new StaticEntityRepository([new SalesChannelCollection()]));

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