Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
restoreByOrder example
'name' => 'Test rule',
'priority' => 1,
'conditions' =>
[
[
'type'
=>
(
new
AlwaysValidRule
(
)
)
->
getName
(
)
]
,
]
,
]
;
// Create rule after create order
$this
->
getContainer
(
)
->
get
(
'rule.repository'
)
->
create
(
[
$rule
]
,
$context
)
;
$saleChanelContext
=
$this
->contextRestorer->
restoreByOrder
(
$ids
->
create
(
'order'
)
,
$context
)
;
static
::
assertTrue
(
\
in_array
(
$ruleId
,
$saleChanelContext
->
getRuleIds
(
)
, true
)
)
;
}
public
function
testRestoreByCustomer
(
)
: void
{
$context
= Context::
createDefaultContext
(
)
;
$ids
=
new
TestDataCollection
(
)
;
$this
->
createOrder
(
$ids
)
;
$ruleId
= Uuid::
randomHex
(
)
;
$rule
=
[
'id' =>
$ruleId
,