Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createComplexRules example
$paymentMethodRepo
=
$this
->
getContainer
(
)
->
get
(
'payment_method.repository'
)
;
$paymentMethod
=
$paymentMethodRepo
->
search
(
$criteria
,
$defaultContext
)
->
getEntities
(
)
->
first
(
)
;
static
::
assertNotNull
(
$paymentMethod
)
;
static
::
assertSame
(
$rule
[
0
]
[
'id'
]
?? null,
$paymentMethod
->
getAvailabilityRule
(
)
?->
getId
(
)
)
;
}
public
function
testRuleAssociationsStayLikeLinked
(
)
: void
{
$defaultContext
= Context::
createDefaultContext
(
)
;
$ruleId
= Uuid::
randomHex
(
)
;
$rules
=
$this
->
createComplexRules
(
$ruleId
)
;
$this
->ruleRepository->
create
(
$rules
,
$defaultContext
)
;
$criteria1
=
new
Criteria
(
[
'id' =>
$ruleId
]
)
;
$criteria1
->
addAssociation
(
'paymentMethods'
)
;
$criteria2
=
new
Criteria
(
[
'id' =>
$rules
[
1
]
[
'id'
]
]
)
;
$criteria2
->
addAssociation
(
'paymentMethods'
)
;
/** @var RuleEntity $rule1 */
$rule1
=
$this
->ruleRepository->
search
(
$criteria1
,
$defaultContext
)
->
first
(
)
;