Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
UserPasswordHasher example
$mockHasher
->
expects
(
$this
->
any
(
)
)
->
method
(
'hash'
)
->
with
(
$this
->
equalTo
(
'plainPassword'
)
,
$this
->
equalTo
(
'userSalt'
)
)
->
willReturn
(
'hash'
)
;
$mockPasswordHasherFactory
=
$this
->
createMock
(
PasswordHasherFactoryInterface::
class
)
;
$mockPasswordHasherFactory
->
expects
(
$this
->
any
(
)
)
->
method
(
'getPasswordHasher'
)
->
with
(
$user
)
->
willReturn
(
$mockHasher
)
;
$passwordHasher
=
new
UserPasswordHasher
(
$mockPasswordHasherFactory
)
;
$encoded
=
$passwordHasher
->
hashPassword
(
$user
, 'plainPassword'
)
;
$this
->
assertEquals
(
'hash',
$encoded
)
;
}
public
function
testHashWithPasswordAuthenticatedUser
(
)
{
$user
=
new
TestPasswordAuthenticatedUser
(
)
;
$mockHasher
=
$this
->
createMock
(
PasswordHasherInterface::
class
)
;
$mockHasher
->
expects
(
$this
->
any
(
)
)