Skip to content

Commit

Permalink
[SecurityHttp] Don't call createMock() with multiple interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Sep 7, 2020
1 parent 6035034 commit 342fefb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Http\Tests\Authenticator\Fixtures;

use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;

abstract class PasswordUpgraderProvider implements UserProviderInterface, PasswordUpgraderInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\User;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
Expand All @@ -25,6 +24,7 @@
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge;
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Http\Tests\Authenticator\Fixtures\PasswordUpgraderProvider;

class FormLoginAuthenticatorTest extends TestCase
{
Expand Down Expand Up @@ -148,7 +148,7 @@ public function testUpgradePassword()
$request = Request::create('/login_check', 'POST', ['_username' => 'wouter', '_password' => 's$cr$t']);
$request->setSession($this->createSession());

$this->userProvider = $this->createMock([UserProviderInterface::class, PasswordUpgraderInterface::class]);
$this->userProvider = $this->createMock(PasswordUpgraderProvider::class);
$this->userProvider->expects($this->any())->method('loadUserByUsername')->willReturn(new User('test', 's$cr$t'));

$this->setUpAuthenticator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Symfony\Component\Security\Http\Authenticator\HttpBasicAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
use Symfony\Component\Security\Http\Tests\Authenticator\Fixtures\PasswordUpgraderProvider;

class HttpBasicAuthenticatorTest extends TestCase
{
Expand Down Expand Up @@ -77,7 +78,7 @@ public function testUpgradePassword()
'PHP_AUTH_PW' => 'ThePassword',
]);

$this->userProvider = $this->createMock([UserProviderInterface::class, PasswordUpgraderInterface::class]);
$this->userProvider = $this->createMock(PasswordUpgraderProvider::class);
$this->userProvider->expects($this->any())->method('loadUserByUsername')->willReturn(new User('test', 's$cr$t'));
$authenticator = new HttpBasicAuthenticator('test', $this->userProvider);

Expand Down

0 comments on commit 342fefb

Please sign in to comment.