Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setLastOrderDate example
public
function
testRuleMatchesWithDayBefore
(
)
: void
{
$checkoutContext
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$customer
=
new
CustomerEntity
(
)
;
$datetime
= self::
getTestTimestamp
(
)
;
$checkoutContext
->
method
(
'getCustomer'
)
->
willReturn
(
$customer
)
;
$customer
->
setLastOrderDate
(
$datetime
->
modify
(
'-1 day'
)
)
;
$scope
=
$this
->
createMock
(
CheckoutRuleScope::
class
)
;
$scope
->
method
(
'getCurrentTime'
)
->
willReturn
(
self::
getTestTimestamp
(
)
)
;
$scope
->
method
(
'getSalesChannelContext'
)
->
willReturn
(
$checkoutContext
)
;
$rule
=
new
DaysSinceLastOrderRule
(
)
;
$rule
->
assign
(
[
'daysPassed' => 1, 'operator' => Rule::OPERATOR_EQ
]
)
;
static
::
assertTrue
(
$rule
->
match
(
$scope
)
)
;
}