TestPasswordAuthenticatedUser example

->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())
            ->method('hash')
            ->with($this->equalTo('plainPassword')$this->equalTo(null))
            ->willReturn('hash');

        $mockPasswordHasherFactory = $this->createMock(PasswordHasherFactoryInterface::class);
        $mockPasswordHasherFactory->expects($this->any())
            ->method('getPasswordHasher')
            ->with($user)
            
Home | Imprint | This part of the site doesn't use cookies.