StateMachineStateEntity example

$queryBuilder->method('executeQuery')->willReturn($result);

        $connection = $this->getConnectionMock();
        $connection->method('createQueryBuilder')->willReturn($queryBuilder);

        $stockUpdater = new StockUpdater(
            $connection,
            $this->dispatcher,
            new StockUpdateFilterProvider([$filter]),
        );

        $fromStateEntity = new StateMachineStateEntity();
        $fromStateEntity->setTechnicalName(OrderStates::STATE_OPEN);

        $toStateEntity = new StateMachineStateEntity();
        $toStateEntity->setTechnicalName(OrderStates::STATE_CANCELLED);

        $event = new StateMachineTransitionEvent(
            OrderDefinition::ENTITY_NAME,
            $this->ids->get('order1'),
            $fromStateEntity,
            $toStateEntity,
            Context::createDefaultContext()
        );
'id' => 'item-1',
                    'state' => ['quantity' => 15, 'referenced_id' => 'product-2'],
                ],
            ],
        ];
    }

    public function testStateChangeCanBeDisabled(): void
    {
        $context = Context::createDefaultContext()->createWithVersionId($this->ids->create('version'));

        $fromState = new StateMachineStateEntity();
        $fromState->setTechnicalName(OrderStates::STATE_OPEN);

        $toState = new StateMachineStateEntity();
        $toState->setTechnicalName(OrderStates::STATE_CANCELLED);

        $event = new StateMachineTransitionEvent(
            OrderDefinition::ENTITY_NAME,
            $this->ids->get('order-1'),
            $fromState,
            $toState,
            $context
        );

        if ($toManipulate !== 'order-no-order-deliveries') {
            $orderDeliveryCollection->add($orderDelivery);
        }

        // Transactions         $orderTransactionCollection = new OrderTransactionCollection();

        $orderTransaction = new OrderTransactionEntity();
        $orderTransaction->setId('order-transaction-id');
        $orderTransaction->setPaymentMethodId('order-transaction-payment-method-id');
        $stateMachineState = new StateMachineStateEntity();
        $stateMachineState->setId('state-machine-state-id');
        $stateMachineState->setTechnicalName('state-machine-state-technical-name');
        $orderTransaction->setStateMachineState($stateMachineState);

        $orderTransactionCancelled = new OrderTransactionEntity();
        $orderTransactionCancelled->setId('order-transaction-cancelled-id');
        $orderTransactionCancelled->setPaymentMethodId('order-transaction-cancelled-payment-method-id');
        $stateMachineStateCancelled = new StateMachineStateEntity();
        $stateMachineStateCancelled->setId('state-machine-cancelled-state-id');
        $stateMachineStateCancelled->setTechnicalName('cancelled');
        $orderTransactionCancelled->setStateMachineState($stateMachineStateCancelled);

        
static::assertEquals(RuleConstraints::uuids()$constraints['stateIds']);
        static::assertEquals(RuleConstraints::uuidOperators(false)$constraints['operator']);
    }

    /** * @dataProvider getMatchingValues * * @param list<string> $selectedOrderStateIds */
    public function testOrderPaymentStatusRuleMatching(bool $expected, string $orderStateId, array $selectedOrderStateIds, string $operator): void
    {
        $stateMachineState = new StateMachineStateEntity();
        $stateMachineState->setTechnicalName(OrderTransactionStates::STATE_IN_PROGRESS);
        $orderTransactionCollection = new OrderTransactionCollection();
        $orderTransaction = new OrderTransactionEntity();
        $orderTransaction->setId(Uuid::randomHex());
        $orderTransaction->setStateId($orderStateId);
        $orderTransaction->setStateMachineState($stateMachineState);
        $orderTransactionCollection->add($orderTransaction);
        $order = new OrderEntity();
        $order->setTransactions($orderTransactionCollection);

        $cart = $this->createMock(Cart::class);
        
Home | Imprint | This part of the site doesn't use cookies.