Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setCalculationRuleId example
$shippingMethod
->
setTaxType
(
ShippingMethodEntity::TAX_TYPE_AUTO
)
;
$price
=
new
ShippingMethodPriceEntity
(
)
;
$price
->
setUniqueIdentifier
(
Uuid::
randomHex
(
)
)
;
$price
->
setCurrencyPrice
(
new
PriceCollection
(
[
new
Price
(
Defaults::CURRENCY,
12,
12,
false
)
,
]
)
)
;
$price
->
setCalculationRuleId
(
$validRuleId
)
;
$shippingMethod
->
setPrices
(
new
ShippingMethodPriceCollection
(
[
$price
]
)
)
;
$context
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$baseContext
= Context::
createDefaultContext
(
)
;
$context
->
expects
(
static
::
atLeastOnce
(
)
)
->
method
(
'getContext'
)
->
willReturn
(
$baseContext
)
;
$context
->
expects
(
static
::
atLeastOnce
(
)
)
->
method
(
'getRuleIds'
)
->
willReturn
(
[
$validRuleId
]
)
;
$context
->
expects
(
static
::
atLeastOnce
(
)
)
->
method
(
'getShippingMethod'
)
->
willReturn
(
$shippingMethod
)
;
$context
->
method
(
'getItemRounding'
)
->
willReturn
(
new
CashRoundingConfig
(
2, 0.01, true
)
)
;