ProductExportGenerateTaskHandler example

/** * @dataProvider shouldBeRunDataProvider */
    public function testShouldBeRun(ProductExportEntity $productExportEntity, bool $expectedResult): void
    {
        $salesChannelRepositoryMock = $this->getSalesChannelRepositoryMock();
        $salesChannelContextFactoryMock = $this->getSalesChannelContextFactoryMock();
        $productExportRepositoryMock = $this->getProductExportRepositoryMock($productExportEntity);

        $messageBusMock = new CollectingMessageBus();

        $productExportGenerateTaskHandler = new ProductExportGenerateTaskHandler(
            $this->createMock(EntityRepository::class),
            $salesChannelContextFactoryMock,
            $salesChannelRepositoryMock,
            $productExportRepositoryMock,
            $messageBusMock
        );

        $productExportGenerateTaskHandler->run();

        if ($expectedResult) {
            static::assertCount(1, $messageBusMock->getMessages());
        }
'languageId' => $originalSalesChannel->getLanguageId(),
            'paymentMethodId' => $this->getValidPaymentMethodId(),
            'shippingMethodId' => $this->getValidShippingMethodId(),
            'navigationCategoryId' => $this->getValidCategoryId(),
            'countryId' => $this->getValidCountryId(),
        ];
        $salesChannelRepository->create([$data]$this->context);
    }

    private function getTaskHandler(): ProductExportGenerateTaskHandler
    {
        return new ProductExportGenerateTaskHandler(
            $this->getContainer()->get('scheduled_task.repository'),
            $this->getContainer()->get(SalesChannelContextFactory::class),
            $this->getContainer()->get('sales_channel.repository'),
            $this->getContainer()->get('product_export.repository'),
            $this->getContainer()->get('messenger.bus.shopware')
        );
    }

    private function getSalesChannelId(): string
    {
        /** @var EntityRepository $repository */
        
Home | Imprint | This part of the site doesn't use cookies.