Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createListener example
/** * @runInSeparateProcess */
public
function
testPhpBridgeAlreadyStartedSession
(
)
{
session_start
(
)
;
$sessionId
=
session_id
(
)
;
$request
=
new
Request
(
)
;
$listener
=
$this
->
createListener
(
$request
,
new
PhpBridgeSessionStorageFactory
(
)
)
;
$event
=
new
RequestEvent
(
$this
->
createMock
(
HttpKernelInterface::
class
)
,
$request
, HttpKernelInterface::MAIN_REQUEST
)
;
$listener
->
onKernelRequest
(
$event
)
;
$this
->
assertTrue
(
$request
->
hasSession
(
)
)
;
$this
->
assertSame
(
$sessionId
,
$request
->
getSession
(
)
->
getId
(
)
)
;
}
/** * @runInSeparateProcess */
$this
->ldap =
$this
->
createMock
(
LdapInterface::
class
)
;
}
/** * @dataProvider provideShouldNotCheckPassport */
public
function
testShouldNotCheckPassport
(
$authenticator
,
$passport
)
{
$this
->ldap->
expects
(
$this
->
never
(
)
)
->
method
(
'bind'
)
;
$listener
=
$this
->
createListener
(
)
;
$listener
->
onCheckPassport
(
new
CheckPassportEvent
(
$authenticator
,
$passport
)
)
;
}
public
static
function
provideShouldNotCheckPassport
(
)
{
// no LdapBadge
yield
[
new
TestAuthenticator
(
)
,
new
Passport
(
new
UserBadge
(
'test'
)
,
new
PasswordCredentials
(
's3cret'
)
)
]
;
// ldap already resolved
$badge
=
new
LdapBadge
(
'app.ldap'
)
;
$badge
->
markResolved
(
)
;