CodeExplorer createSimpleRule example
private EntityRepository
$ruleRepository;
protected function setUp(): void
{ $this->ruleRepository =
$this->
getContainer()->
get('rule.repository'
);
} public function testIfPaymentMethodAssociatedWithRuleCanBeAccessed(): void
{ $defaultContext = Context::
createDefaultContext();
$rule =
$this->
createSimpleRule();
$this->ruleRepository->
create($rule,
$defaultContext);
$criteria =
new Criteria([$rule[0
]['id'
]]);
$criteria->
addAssociation('paymentMethods'
);
$searchedRule =
$this->ruleRepository->
search($criteria,
$defaultContext)->
getEntities()->
first();
static::
assertNotNull($searchedRule);
static::
assertSame($rule[0
]['id'
] ?? null,
$searchedRule->
getId());
static::
assertSame( $rule[0
]['paymentMethods'
][0
]['id'
] ?? null,