Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getTestRule example
'created_at'
=>
(
new
\
DateTimeImmutable
(
)
)
->
format
(
'Y-m-d H:i:s'
)
,
]
;
}
public
function
testUpdate
(
)
: void
{
$this
->
addTestConditions
(
)
;
static
::
assertGreaterThanOrEqual
(
1,
$this
->
getLineItemsInCartRuleConditions
(
)
)
;
$this
->migration->
update
(
$this
->connection
)
;
static
::
assertCount
(
0,
$this
->
getLineItemsInCartRuleConditions
(
)
)
;
static
::
assertNull
(
$this
->
getTestRule
(
)
[
'payload'
]
, 'the migrated rule payload should be empty'
)
;
$this
->
removeTestConditions
(
)
;
}
/** * @return array<string, mixed>[] */
private
function
getLineItemsInCartRuleConditions
(
)
: array
{
return
$this
->connection->
fetchAllAssociative
(
'SELECT * FROM rule_condition WHERE type="cartLineItemsInCart"'
)
;
}
}
public
function
testUpdate
(
)
: void
{
$this
->
addTestConditions
(
)
;
static
::
assertGreaterThanOrEqual
(
1,
$this
->
getIsNewCustomerConditions
(
)
)
;
$this
->migration->
update
(
$this
->connection
)
;
$this
->migration->
update
(
$this
->connection
)
;
static
::
assertCount
(
0,
$this
->
getIsNewCustomerConditions
(
)
)
;
static
::
assertNull
(
$this
->
getTestRule
(
)
[
'payload'
]
, 'the migrated rule payload should be empty'
)
;
$value
=
json_decode
(
(string)
$this
->
getDaysSinceFirstLoginConditions
(
)
[
'value'
]
, true, 512, \JSON_THROW_ON_ERROR
)
;
static
::
assertEquals
(
'=',
$value
[
'operator'
]
)
;
static
::
assertEquals
(
0,
$value
[
'daysPassed'
]
)
;
$this
->
removeTestConditions
(
)
;
}
/** * @return array<string, mixed>[] */
private
function
getIsNewCustomerConditions
(
)
: array
{