private UserInterface&PasswordAuthenticatedUserInterface
$user;
protected function setUp(): void
{ $this->user =
$this->
createMock(TestPasswordAuthenticatedUser::
class);
$this->user->
expects($this->
any())->
method('getPassword'
)->
willReturn('old-hash'
);
$encoder =
$this->
createMock(PasswordHasherInterface::
class);
$encoder->
expects($this->
any())->
method('needsRehash'
)->
willReturn(true
);
$encoder->
expects($this->
any())->
method('hash'
)->
with('pa$$word', null
)->
willReturn('new-hash'
);
$this->hasherFactory =
$this->
createMock(PasswordHasherFactoryInterface::
class);
$this->hasherFactory->
expects($this->
any())->
method('getPasswordHasher'
)->
with($this->user
)->
willReturn($encoder);
$this->listener =
new PasswordMigratingListener($this->hasherFactory
);
} /**
* @dataProvider provideUnsupportedEvents
*/
public function testUnsupportedEvents($event) { $this->hasherFactory->
expects($this->
never())->
method('getPasswordHasher'
);
$this->listener->
onLoginSuccess($event);
}