Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
NonePersistentError example
$calculatedTaxForProductItem
=
array_filter
(
$shippingCalculatedTaxes
,
fn
(
CalculatedTax
$tax
)
=>
(int)
$tax
->
getTaxRate
(
)
===
$taxForProductItem
)
;
static
::
assertNotEmpty
(
$calculatedTaxForProductItem
)
;
static
::
assertCount
(
1,
$calculatedTaxForProductItem
)
;
}
public
function
testPersistentErrors
(
)
: void
{
$cart
=
new
Cart
(
Uuid::
randomHex
(
)
)
;
$cart
->
addErrors
(
new
NonePersistentError
(
)
,
new
PersistentError
(
)
)
;
$cart
=
$this
->
getContainer
(
)
->
get
(
Processor::
class
)
->
process
(
$cart
,
$this
->context,
new
CartBehavior
(
)
)
;
static
::
assertCount
(
1,
$cart
->
getErrors
(
)
)
;
static
::
assertInstanceOf
(
PersistentError::
class
,
$cart
->
getErrors
(
)
->
first
(
)
)
;
$error
=
$cart
->
getErrors
(
)
->
first
(
)
;
static
::
assertEquals
(
'persistent',
$error
->
getId
(
)
)
;
static
::
assertEquals
(
'persistent',
$error
->
getMessageKey
(
)
)
;
}