Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
generateDeliveryTimeDummy example
$cart
=
new
Cart
(
'test'
)
;
$validator
=
new
DeliveryValidator
(
)
;
$errors
=
new
ErrorCollection
(
)
;
$validator
->
validate
(
$cart
,
$errors
,
$this
->
createMock
(
SalesChannelContext::
class
)
)
;
static
::
assertCount
(
0,
$errors
)
;
}
public
function
testValidateWithoutRules
(
)
: void
{
$deliveryTime
=
$this
->
generateDeliveryTimeDummy
(
)
;
$cart
=
new
Cart
(
'test'
)
;
$context
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$shippingMethod
=
new
ShippingMethodEntity
(
)
;
$shippingMethod
->
setId
(
'1'
)
;
$shippingMethod
->
setAvailabilityRuleId
(
'1'
)
;
$shippingMethod
->
setDeliveryTime
(
$deliveryTime
)
;
$shippingMethod
->
setActive
(
true
)
;
$deliveryDate
=
new
DeliveryDate
(
new
\
DateTime
(
)
,
new
\
DateTime
(
)
)
;
$delivery
=
new
Delivery
(
new
DeliveryPositionCollection
(
)
,
$factor
= 1.1;
$this
->salesChannelContext->
getContext
(
)
->
assign
(
[
'currencyFactor' =>
$factor
]
)
;
$deliveryProcessor
=
$this
->
getContainer
(
)
->
get
(
DeliveryProcessor::
class
)
;
$cartDataCollection
=
new
CartDataCollection
(
)
;
$cartDataCollection
->
set
(
DeliveryProcessor::
buildKey
(
$this
->salesChannelContext->
getShippingMethod
(
)
->
getId
(
)
)
,
$this
->salesChannelContext->
getShippingMethod
(
)
)
;
$originalCart
=
new
Cart
(
'original'
)
;
$deliveryTime
=
$this
->
generateDeliveryTimeDummy
(
)
;
$shippingMethod
=
new
ShippingMethodEntity
(
)
;
$shippingMethod
->
setId
(
'1'
)
;
$shippingMethod
->
setName
(
'Express'
)
;
$shippingMethod
->
addTranslated
(
'name', 'Express'
)
;
$shippingMethod
->
setDeliveryTime
(
$deliveryTime
)
;
$shippingMethod
->
setAvailabilityRuleId
(
Uuid::
randomHex
(
)
)
;
$shippingMethod
->
setTaxType
(
ShippingMethodEntity::TAX_TYPE_AUTO
)
;
$deliveryDate
=
new
DeliveryDate
(
new
\
DateTime
(
)
,
new
\
DateTime
(
)
)
;
$delivery
=
new
Delivery
(