Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
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
(
)
)
;
}