createUserWithId example

$migration = new Migration1625819412ChangeOrderCreatedByIdConstraint();
        $migration->update($this->connection);

        $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.