Skip to content

Commit

Permalink
Fix UserPasswordCommand?
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed Nov 12, 2021
1 parent e0d6d9a commit 06f9778
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion core-bundle/src/Command/UserPasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;

/**
* Changes the password of a Contao back end user.
Expand Down
22 changes: 11 additions & 11 deletions core-bundle/tests/Command/UserPasswordCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
use Symfony\Component\PasswordHasher\PasswordHasherInterface;

class UserPasswordCommandTest extends TestCase
{
Expand Down Expand Up @@ -245,21 +245,21 @@ private function getCommand(Connection $connection = null, string $password = nu
$password = '12345678';
}

$encoder = $this->createMock(PasswordEncoderInterface::class);
$encoder
->method('encodePassword')
->with($password, null)
$passwordHasher = $this->createMock(PasswordHasherInterface::class);
$passwordHasher
->method('hash')
->with($password)
->willReturn('$argon2id$v=19$m=65536,t=6,p=1$T+WK0xPOk21CQ2dX9AFplw$2uCrfvt7Tby81Dhc8Y7wHQQGP1HnPC3nDEb4FtXsfrQ')
;

$encoderFactory = $this->createMock(EncoderFactoryInterface::class);
$encoderFactory
->method('getEncoder')
$passwordHasherFactory = $this->createMock(PasswordHasherFactoryInterface::class);
$passwordHasherFactory
->method('getPasswordHasher')
->with(BackendUser::class)
->willReturn($encoder)
->willReturn($passwordHasher)
;

$command = new UserPasswordCommand($this->mockContaoFramework(), $connection, $encoderFactory);
$command = new UserPasswordCommand($this->mockContaoFramework(), $connection, $passwordHasherFactory);
$command->setApplication(new Application());

return $command;
Expand Down

0 comments on commit 06f9778

Please sign in to comment.