Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
DeliveryCalculator example
$data
=
new
CartDataCollection
(
)
;
$cart
=
new
Cart
(
'test'
)
;
$cartBehavior
=
new
CartBehavior
(
[
DeliveryProcessor::SKIP_DELIVERY_PRICE_RECALCULATION => true,
]
)
;
$cart
->
setBehavior
(
$cartBehavior
)
;
$quantityPriceCalculatorMock
=
$this
->
createMock
(
QuantityPriceCalculator::
class
)
;
$quantityPriceCalculatorMock
->
expects
(
static
::
once
(
)
)
->
method
(
'calculate'
)
->
willReturn
(
$costs
)
;
$deliveryCalculator
=
new
DeliveryCalculator
(
$quantityPriceCalculatorMock
,
$this
->
createMock
(
PercentageTaxRuleBuilder::
class
)
,
)
;
$deliveryCalculator
->
calculate
(
$data
,
$cart
,
new
DeliveryCollection
(
[
$delivery
]
)
,
$context
)
;
static
::
assertNotNull
(
$newCosts
)
;
static
::
assertSame
(
$costs
->
getUnitPrice
(
)
,
$newCosts
->
getUnitPrice
(
)
)
;
static
::
assertSame
(
$costs
->
getTotalPrice
(
)
,
$newCosts
->
getTotalPrice
(
)
)
;
}
}