createOrderPayload example


    use DataAbstractionLayerFieldTestBehaviour;
    use IntegrationTestBehaviour;

    public function testCreatedByNotCreateWithWrongScope(): void
    {
        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');
        $userId = $this->fetchFirstIdFromTable('user');
        $context = $this->getAdminContext($userId);

        $payload = $this->createOrderPayload();
        $orderRepository->create([$payload]$context);

        $result = $orderRepository->search(
            new Criteria([$payload['id']]),
            $context
        )->first();

        static::assertNull($result->getCreatedById());
    }

    public function testCreatedByNotCreateWithWrongSource(): void
    {

    use DataAbstractionLayerFieldTestBehaviour;
    use IntegrationTestBehaviour;

    public function testUpdatedByNotUpdateWithWrongScope(): void
    {
        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');
        $userId = $this->fetchFirstIdFromTable('user');
        $context = $this->getAdminContext($userId);

        $payload = $this->createOrderPayload();
        $orderRepository->create([$payload]$context);

        $orderRepository->update([
            [
                'id' => $payload['id'],
                'orderDateTime' => (new \DateTimeImmutable())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            ],
        ]$context);

        $result = $orderRepository->search(
            new Criteria([$payload['id']]),
            

        parent::setUp();

        $this->orderRepository = $this->getContainer()->get('order.repository');
        $this->connection = $this->getContainer()->get(Connection::class);
        $this->context = Context::createDefaultContext();
    }

    public function testEncodeEveryStateMachineStateIdAllowedWhenCreatingEntity(): void
    {
        $payload = array_merge(
            $this->createOrderPayload(),
            [
                'stateId' => $this->fetchOrderStateId(OrderStates::STATE_COMPLETED),
            ]
        );

        $this->context->scope(Context::USER_SCOPE, function DContext $context) use ($payload): void {
            $this->orderRepository->create([$payload]$context);
        });

        // Expect no exception was thrown         $this->addToAssertionCount(1);
    }
$this->connection->beginTransaction();
    }

    public function testItChangesOrderCreatedByIdConstraint(): void
    {
        $context = Context::createDefaultContext();
        $userId = Uuid::randomHex();

        $userRepository = $this->createUserWithId($userId);

        $orderPayload = $this->createOrderPayload();
        $orderPayload['createdById'] = $userId;
        $orderRepository = $this->getContainer()->get('order.repository');
        $orderRepository->create([$orderPayload]$context);

        $userRepository->delete([['id' => $userId]]$context);

        /** @var OrderEntity $order */
        $order = $orderRepository->search(new Criteria([$orderPayload['id']])$context)->first();
        static::assertNull($order->getCreatedById());
    }

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