Skip to content

Commit

Permalink
Remove unnecessary compatibility checks in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Jun 25, 2024
1 parent c079a95 commit 16863df
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 38 deletions.
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
31 changes: 1 addition & 30 deletions tests/Security/LoginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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
Expand All @@ -33,10 +32,6 @@ public function testLogInUserWithRequestStack()

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

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

Expand All @@ -49,31 +44,7 @@ public function testLogInUserWithRememberMeHandler()
$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(string $firewallName, ?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

0 comments on commit 16863df

Please sign in to comment.