Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ExcludeFlowEventHandler example
/** * @param list<string> $excludeList * * @dataProvider cases */
public
function
testHandler
(
LogRecord
$record
, array
$excludeList
, bool
$shouldBePassed
)
: void
{
$innerHandler
=
$this
->
createMock
(
FingersCrossedHandler::
class
)
;
$innerHandler
->
expects
(
$shouldBePassed
?
static
::
once
(
)
:
static
::
never
(
)
)
->
method
(
'handle'
)
->
willReturn
(
true
)
;
$handler
=
new
ExcludeFlowEventHandler
(
$innerHandler
,
$excludeList
)
;
$handler
->
handle
(
$record
)
;
}
/** * @return iterable<string, array{0: LogRecord, 1: list<string>, 2: bool}> */
public
static
function
cases
(
)
: iterable
{
)
;
static
::
assertEquals
(
400,
$this
->
getBrowser
(
)
->
getResponse
(
)
->
getStatusCode
(
)
)
;
}
public
function
testCreateUserRecovery
(
)
: void
{
$logger
=
$this
->
getContainer
(
)
->
get
(
'monolog.logger.business_events'
)
;
$handlers
=
$logger
->
getHandlers
(
)
;
$logger
->
setHandlers
(
[
new
ExcludeFlowEventHandler
(
$this
->
getContainer
(
)
->
get
(
DoctrineSQLHandler::
class
)
,
[
UserRecoveryRequestEvent::EVENT_NAME,
]
)
,
]
)
;
$dispatchedEvent
= null;
$this
->
addEventListener
(
$this
->
getContainer
(
)
->
get
(
'event_dispatcher'
)
,
UserRecoveryRequestEvent::EVENT_NAME,
function
DUserRecoveryRequestEvent
$event
)
use
(
&
$dispatchedEvent
)
: void
{
$dispatchedEvent
=
$event
;
}
,
$response
=
$controller
->
login
(
$request
,
new
RequestDataBag
(
$request
->attributes->
all
(
)
)
,
$this
->salesChannelContext
)
;
static
::
assertEquals
(
200,
$response
->
getStatusCode
(
)
)
;
}
public
function
testGenerateAccountRecovery
(
)
: void
{
$logger
=
$this
->
getContainer
(
)
->
get
(
'monolog.logger.business_events'
)
;
$handlers
=
$logger
->
getHandlers
(
)
;
$logger
->
setHandlers
(
[
new
ExcludeFlowEventHandler
(
$this
->
getContainer
(
)
->
get
(
DoctrineSQLHandler::
class
)
,
[
CustomerAccountRecoverRequestEvent::EVENT_NAME,
]
)
,
]
)
;
$testSubscriber
=
new
AuthTestSubscriber
(
)
;
$this
->
getContainer
(
)
->
get
(
'event_dispatcher'
)
->
addSubscriber
(
$testSubscriber
)
;
/** @var CustomerEntity|null $customer */
$customer
=
$this
->
createCustomer
(
)
;
static
::
assertNotNull
(
$customer
)
;