Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
isSynchronous example
'payment_method.partial_loaded' => 'formatHandlerIdentifier',
]
;
}
public
function
formatHandlerIdentifier
(
EntityLoadedEvent
$event
)
: void
{
/** @var Entity $entity */
foreach
(
$event
->
getEntities
(
)
as
$entity
)
{
$entity
->
assign
(
[
'shortName' =>
$this
->
getShortName
(
$entity
)
,
'formattedHandlerIdentifier' =>
$this
->
getHandlerIdentifier
(
$entity
)
,
'synchronous' =>
$this
->
isSynchronous
(
$entity
)
,
'asynchronous' =>
$this
->
isAsynchronous
(
$entity
)
,
'prepared' =>
$this
->
isPrepared
(
$entity
)
,
'refundable' =>
$this
->
isRefundable
(
$entity
)
,
'recurring' =>
$this
->
isRecurring
(
$entity
)
,
]
)
;
}
}
private
function
getHandlerIdentifier
(
Entity
$entity
)
: string
{
$explodedHandlerIdentifier
=
explode
(
'\\',
(string)
$entity
->
get
(
'handlerIdentifier'
)
)
;
$methods
=
$event
->
getEntities
(
)
;
static
::
assertContainsOnly
(
PaymentMethodEntity::
class
,
$methods
)
;
static
::
assertCount
(
5,
$methods
)
;
static
::
assertSame
(
'handler_shopware_synchronouspaymenthandlerinterface',
$methods
[
0
]
->
getFormattedHandlerIdentifier
(
)
)
;
static
::
assertSame
(
'handler_shopware_asynchronouspaymenthandlerinterface',
$methods
[
1
]
->
getFormattedHandlerIdentifier
(
)
)
;
static
::
assertSame
(
'handler_shopware_refundpaymenthandlerinterface',
$methods
[
2
]
->
getFormattedHandlerIdentifier
(
)
)
;
static
::
assertSame
(
'handler_shopware_preparedpaymenthandlerinterface',
$methods
[
3
]
->
getFormattedHandlerIdentifier
(
)
)
;
static
::
assertSame
(
'handler_shopware_recurringpaymenthandlerinterface',
$methods
[
4
]
->
getFormattedHandlerIdentifier
(
)
)
;
static
::
assertTrue
(
$methods
[
0
]
->
isSynchronous
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isAsynchronous
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isRefundable
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isPrepared
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isRecurring
(
)
)
;
static
::
assertFalse
(
$methods
[
1
]
->
isSynchronous
(
)
)
;
static
::
assertTrue
(
$methods
[
1
]
->
isAsynchronous
(
)
)
;
static
::
assertFalse
(
$methods
[
1
]
->
isRefundable
(
)
)
;
static
::
assertFalse
(
$methods
[
1
]
->
isPrepared
(
)
)
;
static
::
assertFalse
(
$methods
[
1
]
->
isRecurring
(
)
)
;
->
willReturn
(
$this
->
getPaymentMethodEntity
(
$this
->
createMock
(
SynchronousPaymentHandlerInterface::
class
)
::
class
D
)
;
(
new
PaymentHandlerIdentifierSubscriber
(
)
)
->
formatHandlerIdentifier
(
$event
)
;
static
::
assertCount
(
1,
$event
->
getEntities
(
)
)
;
/** @var PaymentMethodEntity $paymentMethod */
$paymentMethod
=
$event
->
getEntities
(
)
[
0
]
;
static
::
assertTrue
(
$paymentMethod
->
isSynchronous
(
)
)
;
static
::
assertFalse
(
$paymentMethod
->
isAsynchronous
(
)
)
;
static
::
assertFalse
(
$paymentMethod
->
isPrepared
(
)
)
;
}
public
function
testAsynchronousRuntimeField
(
)
: void
{
$event
=
$this
->
createMock
(
EntityLoadedEvent::
class
)
;
$event
->
method
(
'getEntities'
)
->
willReturn
(
$this
->
getPaymentMethodEntity
(
$this
->
createMock
(
AsynchronousPaymentHandlerInterface::
class
)
::
class
D
)
;