getOrderData example

static::assertFalse($result);
    }

    public function testCustomerMetaFieldSubscriberWithCompletedOrder(): void
    {
        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');
        /** @var EntityRepository $customerRepository */
        $customerRepository = $this->getContainer()->get('customer.repository');
        $defaultContext = Context::createDefaultContext();
        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId$defaultContext);

        $orderRepository->create($orderData$defaultContext);

        $this->stateMachineRegistry->transition(
            new Transition(
                'order',
                $orderId,
                StateMachineTransitionActions::ACTION_PROCESS,
                'stateId',
            ),
            $defaultContext
        );
$this->orderRepository = $this->getContainer()->get('order.repository');
        $this->orderPersister = $this->getContainer()->get(OrderPersister::class);
        $this->customerRepository = $this->getContainer()->get('customer.repository');
        $this->processor = $this->getContainer()->get(Processor::class);
        $this->salesChannelContextFactory = $this->getContainer()->get(SalesChannelContextFactory::class);
    }

    public function testCreateOrder(): void
    {
        $orderId = Uuid::randomHex();
        $defaultContext = Context::createDefaultContext();
        $orderData = $this->getOrderData($orderId$defaultContext);
        $this->orderRepository->create($orderData$defaultContext);

        $nestedCriteria2 = new Criteria();
        $nestedCriteria2->addAssociation('addresses');

        $criteria = new Criteria([$orderId]);

        /** @var OrderEntity|null $order */
        $order = $this->orderRepository->search($criteria$defaultContext)->first();

        static::assertNotNull($order);
        

        $orderId = Uuid::randomHex();
        $customerId = $this->createCustomer('orderTest@example.com', true);

        $this->getContainer()->get('customer.repository')->update([
            [
                'id' => $customerId,
                'salesChannelId' => $this->ids->get('sales-channel'),
            ],
        ]$this->context);

        $orderData = $this->getOrderData($orderId$this->context);
        $orderData[0]['orderCustomer']['customer'] = ['id' => $customerId];
        $orderData[0]['orderCustomer']['email'] = 'orderTest@example.com';
        $orderData[0]['orderCustomer']['addresses'][0]['zipcode'] = '12345';
        $orderData[0]['addresses'][0]['zipcode'] = '12345';
        $orderData[0]['salesChannelId'] = $this->ids->get('sales-channel');

        $orderRepsitory = $this->getContainer()->get('order.repository');
        $orderRepsitory->create($orderData$this->context);

        $order = $orderRepsitory->search(new Criteria([$orderId])$this->context)->first();

        

        $this->addCountriesToSalesChannel();
    }

    public function testAjaxOrderDetail(): void
    {
        $context = Context::createDefaultContext();
        $customer = $this->createCustomer($context);
        $browser = $this->login($customer->getEmail());

        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId$context);
        $orderData[0]['orderCustomer']['customer'] = ['id' => $customer->getId()];

        $criteria = new Criteria();
        $criteria
            ->addFilter(new EqualsFilter('typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT))
            ->addFilter(new EqualsFilter('active', true))
            ->addFilter(new EqualsFilter('domains.url', $_SERVER['APP_URL']));

        /** @var SalesChannelEntity|null $salesChannel */
        $salesChannel = $this->getContainer()->get('sales_channel.repository')->search($criteria$context)->first();

        
$filesystem = $this->getContainer()->get('shopware.filesystem.private');
        $logfile = $this->getLogEntity($progress->getLogId())->getFile();
        static::assertInstanceOf(ImportExportFileEntity::class$logfile);
        $csv = $filesystem->read($logfile->getPath());

        static::assertEquals(file_get_contents(__DIR__ . '/fixtures/promotion_discounts_export.csv')$csv);
    }

    public function testExportOrders(): void
    {
        $orderId = Uuid::randomHex();
        $testOrder = $this->getOrderData($orderId, Context::createDefaultContext())[0];
        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');

        $context = Context::createDefaultContext();
        $orderRepository->upsert([$testOrder]$context);

        $criteria = new Criteria([$testOrder['id']]);
        $progress = $this->export(Context::createDefaultContext(), OrderDefinition::ENTITY_NAME, $criteria);

        static::assertTrue($progress->isFinished());
        static::assertImportExportSucceeded($progress$this->getInvalidLogContent($progress->getInvalidRecordsLogId()));
    }
$configId = Uuid::randomHex();

        $this->documentRepository->create(
            [
                [
                    'documentType' => [
                        'id' => $documentTypeId,
                        'technicalName' => 'testType',
                        'name' => 'test',
                    ],
                    'id' => $documentId,
                    'order' => $this->getOrderData($orderId),
                    'fileType' => 'pdf',
                    'config' => [],
                    'deepLinkCode' => 'deeplink',

                    'documentMediaFile' => [
                        'thumbnails' => [
                            [
                                'id' => Uuid::randomHex(),
                                'width' => 100,
                                'height' => 200,
                                'highDpi' => true,
                            ],
static::assertFalse($rule->match($scope));
    }

    public function testCustomerMetaFieldSubscriber(): void
    {
        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');
        /** @var EntityRepository $customerRepository */
        $customerRepository = $this->getContainer()->get('customer.repository');
        $defaultContext = Context::createDefaultContext();
        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId$defaultContext);

        $orderRepository->create($orderData$defaultContext);

        $this->stateMachineRegistry->transition(
            new Transition(
                'order',
                $orderId,
                StateMachineTransitionActions::ACTION_PROCESS,
                'stateId',
            ),
            Context::createDefaultContext()
        );
$this->createTestFixtureFixedDiscountPromotion(
                $this->ids->get('promotion'),
                70,
                PromotionDiscountEntity::SCOPE_CART,
                $this->ids->get('promotion-code'),
                $this->getContainer(),
                Generator::createSalesChannelContext($context, null, $salesChannel)
            );
        }

        $orderData = $this->getOrderData($this->ids->get('order')$context);
        unset($orderData[0]['orderCustomer']);
        $orderData[0]['lineItems'][] = [
            'id' => $this->ids->get('line-item'),
            'identifier' => '97838d40733d4ae3ad11f4b09f054176',
            'referencedId' => $this->ids->get('promotion-code'),
            'quantity' => 1,
            'label' => 'Test',
            'payload' => [
                'promotionId' => $this->ids->get('promotion'),
                'discountId' => '97838d40733d4ae3ad11f4b09f054176',
                'discountType' => 'percentage',
                

    use DatabaseTransactionBehaviour;
    use KernelTestBehaviour;
    use OrderFixture;

    public function testUpdateOrderTotalAmount(): void
    {
        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');
        $defaultContext = Context::createDefaultContext();
        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId$defaultContext);

        $orderRepository->create($orderData$defaultContext);
        $this->getContainer()->get(StateMachineRegistry::class)->transition(
            new Transition(
                'order',
                $orderId,
                StateMachineTransitionActions::ACTION_PROCESS,
                'stateId',
            ),
            $defaultContext
        );

        


        $this->orderTransactionRepository->upsert([$transaction]$context);

        return $id;
    }

    private function createOrder(Context $context): string
    {
        $orderId = Uuid::randomHex();

        $order = $this->getOrderData($orderId$context);
        $this->orderRepository->upsert($order$context);

        return $orderId;
    }

    private function createPaymentMethod(
        Context $context,
        string $handlerIdentifier = AsyncTestPaymentHandler::class
    D: string {
        $id = Uuid::randomHex();
        $payment = [
            
private function createOrder(): OrderEntity
    {
        // create product         $productId = Uuid::randomHex();
        $product = $this->getProductData($productId);

        /** @var EntityRepository $productRepository */
        $productRepository = $this->getContainer()->get('product.repository');
        $productRepository->create([$product], Context::createDefaultContext());

        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId, Context::createDefaultContext())[0];

        $orderData['lineItems'][0]['productId'] = $productId;

        $this->orderRepository->create([$orderData], Context::createDefaultContext());

        $criteria = new Criteria();

        $criteria->addAssociations([
            'lineItems',
            'billingAddress',
            'deliveries.stateMachineState',
            
'domains' => [
                [
                    'languageId' => Defaults::LANGUAGE_SYSTEM,
                    'currencyId' => Defaults::CURRENCY,
                    'snippetSetId' => $this->getSnippetSetIdForLocale('en-GB'),
                    'url' => 'http://foo.de',
                ],
            ],
        ]);

        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId$this->customerId, $this->email);
        unset($orderData[0]['orderCustomer']['customer']['password']);
        $this->orderRepository->create($orderData, Context::createDefaultContext());

        $this->orderRepository->update([
            [
                'id' => $orderId,
                'salesChannelId' => $testChannel['id'],
            ],
        ], Context::createDefaultContext());

        $this->browser
            
/** * @param array<string, mixed> $config * @param array<string, mixed> $expects * * @dataProvider statusProvider */
    public function testSetOrderStatus(array $config, array $expects): void
    {
        $orderId = Uuid::randomHex();
        $context = Context::createDefaultContext();

        $this->orderRepository->create($this->getOrderData($orderId$context)$context);
        $order = $this->orderRepository->search(new Criteria([$orderId])$context)->first();
        $event = new CheckoutOrderPlacedEvent($context$order, TestDefaults::SALES_CHANNEL);

        $subscriber = new SetOrderStateAction(
            $this->getContainer()->get(Connection::class),
            $this->getContainer()->get('logger'),
            $this->getContainer()->get(OrderService::class)
        );

        /** @var FlowFactory $flowFactory */
        $flowFactory = $this->getContainer()->get(FlowFactory::class);
        
Home | Imprint | This part of the site doesn't use cookies.