Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getAvailabilityRule example
$this
->shippingRepository->
create
(
$shippingMethod
,
$defaultContext
)
;
$criteria
=
new
Criteria
(
[
$this
->shippingMethodId
]
)
;
$criteria
->
addAssociation
(
'availabilityRule'
)
;
$resultSet
=
$this
->shippingRepository->
search
(
$criteria
,
$defaultContext
)
;
/** @var ShippingMethodEntity|null $rule */
$rule
=
$resultSet
->
first
(
)
;
static
::
assertNotNull
(
$rule
)
;
static
::
assertNotNull
(
$rule
->
getAvailabilityRule
(
)
)
;
static
::
assertSame
(
$this
->shippingMethodId,
$rule
->
getId
(
)
)
;
static
::
assertSame
(
$this
->ruleId,
$rule
->
getAvailabilityRule
(
)
->
getId
(
)
)
;
static
::
assertSame
(
$this
->ruleId,
$rule
->
getAvailabilityRuleId
(
)
)
;
}
public
function
testUpdateShippingMethod
(
)
: void
{
$defaultContext
= Context::
createDefaultContext
(
)
;
$shippingMethod
=
$this
->
createShippingMethodDummyArray
(
)
;
public
function
testRulesCanBeAccessedFromShippingMethod
(
)
: void
{
$defaultContext
= Context::
createDefaultContext
(
)
;
$this
->ruleRepository->
create
(
$this
->rule,
$defaultContext
)
;
$criteria
=
new
Criteria
(
[
$this
->rule
[
0
]
[
'shippingMethods'
]
[
0
]
[
'id'
]
]
)
;
$criteria
->
addAssociation
(
'availabilityRule'
)
;
$searchResult
=
$this
->
getContainer
(
)
->
get
(
'shipping_method.repository'
)
->
search
(
$criteria
,
$defaultContext
)
;
static
::
assertSame
(
$this
->ruleId,
$searchResult
->
first
(
)
->
getAvailabilityRule
(
)
->
getId
(
)
)
;
}
public
function
testRuleAssociationsStayLikeLinked
(
)
: void
{
$defaultContext
= Context::
createDefaultContext
(
)
;
$rules
=
$this
->
createComplicatedTestData
(
)
;
$this
->ruleRepository->
create
(
$rules
,
$defaultContext
)
;
$criteria1
=
new
Criteria
(
[
'id' =>
$this
->ruleId
]
)
;
$criteria1
->
addAssociation
(
'shippingMethods'
)
;
$this
->ruleRepository->
create
(
$rule
,
$defaultContext
)
;
$criteria
=
new
Criteria
(
[
$rule
[
0
]
[
'paymentMethods'
]
[
0
]
[
'id'
]
?? ''
]
)
;
$criteria
->
addAssociation
(
'availabilityRule'
)
;
/** @var EntityRepository<PaymentMethodCollection> $paymentMethodRepo */
$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
]
)
;
$this
->paymentRepository->
create
(
$paymentMethod
,
$defaultContext
)
;
$criteria
=
new
Criteria
(
[
$this
->paymentMethodId
]
)
;
$criteria
->
addAssociation
(
'availabilityRule'
)
;
/** @var PaymentMethodCollection $resultSet */
$resultSet
=
$this
->paymentRepository->
search
(
$criteria
,
$defaultContext
)
->
getEntities
(
)
;
$firstPaymentMethod
=
$resultSet
->
first
(
)
;
static
::
assertNotNull
(
$firstPaymentMethod
)
;
static
::
assertSame
(
$this
->paymentMethodId,
$firstPaymentMethod
->
getId
(
)
)
;
static
::
assertNotNull
(
$firstPaymentMethod
->
getAvailabilityRule
(
)
)
;
static
::
assertSame
(
$paymentMethod
[
0
]
[
'availabilityRule'
]
[
'id'
]
,
$firstPaymentMethod
->
getAvailabilityRule
(
)
->
getId
(
)
)
;
static
::
assertSame
(
'handler_shopware_asynctestpaymenthandler',
$firstPaymentMethod
->
getFormattedHandlerIdentifier
(
)
)
;
static
::
assertFalse
(
$firstPaymentMethod
->
getAfterOrderEnabled
(
)
)
;
}