Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary compatibility checks in tests #3086

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/Doctrine/UserManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class UserManagerTest extends TestCase

protected function setUp(): void
{
if (!interface_exists(ObjectManager::class)) {
$this->markTestSkipped('"doctrine/persistence" ^1.3 has to be installed for this test to run.');
}

$passwordUpdater = $this->getMockBuilder('FOS\UserBundle\Util\PasswordUpdaterInterface')->getMock();
$fieldsUpdater = $this->getMockBuilder('FOS\UserBundle\Util\CanonicalFieldsUpdater')
->disableOriginalConstructor()
Expand Down
35 changes: 3 additions & 32 deletions tests/Security/LoginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,18 @@
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\RememberMe\RememberMeHandlerInterface;
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;

class LoginManagerTest extends TestCase
{
public function testLogInUserWithRequestStack()
{
$loginManager = $this->createLoginManager('main');
$loginManager = $this->createLoginManager();
$loginManager->logInUser('main', $this->mockUser());
}

public function testLogInUserWithRememberMeHandler()
{
if (!interface_exists(RememberMeHandlerInterface::class)) {
$this->markTestSkipped('This test requires Symfony 5.3+.');
}

$response = new Response();
$user = $this->mockUser();

Expand All @@ -45,35 +40,11 @@ public function testLogInUserWithRememberMeHandler()
->method('createRememberMeCookie')
->with($user);

$loginManager = $this->createLoginManager('main', $rememberMeHandler);
$loginManager = $this->createLoginManager($rememberMeHandler);
$loginManager->logInUser('main', $user, $response);
}

/**
* @group legacy
*/
public function testLogInUserWithRememberMeService()
{
if (!interface_exists(RememberMeServicesInterface::class)) {
$this->markTestSkipped('This test does not support Symfony 6+.');
}

$response = new Response();

$rememberMeService = $this->createMock(RememberMeServicesInterface::class);
$rememberMeService
->expects($this->once())
->method('loginSuccess')
->with($this->isInstanceOf(Request::class), $response, $this->isInstanceOf(TokenInterface::class));

$loginManager = $this->createLoginManager('main', $rememberMeService);
$loginManager->logInUser('main', $this->mockUser(), $response);
}

/**
* @param RememberMeHandlerInterface|RememberMeServicesInterface|null $rememberMeHandler
*/
private function createLoginManager(string $firewallName, $rememberMeHandler = null): LoginManager
private function createLoginManager(?RememberMeHandlerInterface $rememberMeHandler = null): LoginManager
{
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
$tokenStorage
Expand Down
4 changes: 0 additions & 4 deletions tests/Util/HashingPasswordUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class HashingPasswordUpdaterTest extends TestCase

protected function setUp(): void
{
if (!interface_exists(PasswordHasherFactoryInterface::class)) {
self::markTestSkipped('This test requires having the password-hasher component.');
}

$this->passwordHasherFactory = $this->getMockBuilder(PasswordHasherFactoryInterface::class)->getMock();

$this->updater = new HashingPasswordUpdater($this->passwordHasherFactory);
Expand Down
Loading