Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 9d2f902

Browse files
Make tests support phpunit 8
1 parent 61eea20 commit 9d2f902

20 files changed

+87
-27
lines changed

Core/Tests/Authorization/AuthorizationCheckerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212
namespace Symfony\Component\Security\Core\Tests\Authorization;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
1617
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
1718

1819
class AuthorizationCheckerTest extends TestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
private $authenticationManager;
2124
private $accessDecisionManager;
2225
private $authorizationChecker;
2326
private $tokenStorage;
2427

25-
protected function setUp()
28+
private function doSetUp()
2629
{
2730
$this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
2831
$this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();

Core/Tests/Authorization/Voter/VoterTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1617
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
1718
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1819

1920
class VoterTest extends TestCase
2021
{
22+
use ForwardCompatTestTrait;
23+
2124
protected $token;
2225

23-
protected function setUp()
26+
private function doSetUp()
2427
{
2528
$this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
2629
}

Core/Tests/Encoder/Argon2iPasswordEncoderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@
1212
namespace Symfony\Component\Security\Core\Tests\Encoder;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder;
1617

1718
/**
1819
* @author Zan Baldwin <[email protected]>
1920
*/
2021
class Argon2iPasswordEncoderTest extends TestCase
2122
{
23+
use ForwardCompatTestTrait;
24+
2225
const PASSWORD = 'password';
2326

24-
protected function setUp()
27+
private function doSetUp()
2528
{
2629
if (!Argon2iPasswordEncoder::isSupported()) {
2730
$this->markTestSkipped('Argon2i algorithm is not supported.');

Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Tests\Validator\Constraints;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1516
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
1617
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
@@ -23,6 +24,8 @@
2324
*/
2425
abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase
2526
{
27+
use ForwardCompatTestTrait;
28+
2629
const PASSWORD = 's3Cr3t';
2730
const SALT = '^S4lt$';
2831

@@ -46,7 +49,7 @@ protected function createValidator()
4649
return new UserPasswordValidator($this->tokenStorage, $this->encoderFactory);
4750
}
4851

49-
protected function setUp()
52+
private function doSetUp()
5053
{
5154
$user = $this->createUser();
5255
$this->tokenStorage = $this->createTokenStorage($user);

Csrf/Tests/CsrfTokenManagerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Csrf\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\RequestStack;
1718
use Symfony\Component\Security\Csrf\CsrfToken;
@@ -22,6 +23,8 @@
2223
*/
2324
class CsrfTokenManagerTest extends TestCase
2425
{
26+
use ForwardCompatTestTrait;
27+
2528
/**
2629
* @dataProvider getManagerGeneratorAndStorage
2730
*/
@@ -210,12 +213,12 @@ private function getGeneratorAndStorage()
210213
];
211214
}
212215

213-
protected function setUp()
216+
private function doSetUp()
214217
{
215218
$_SERVER['HTTPS'] = 'on';
216219
}
217220

218-
protected function tearDown()
221+
private function doTearDown()
219222
{
220223
parent::tearDown();
221224

Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
namespace Symfony\Component\Security\Csrf\Tests\TokenGenerator;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator;
1617

1718
/**
1819
* @author Bernhard Schussek <[email protected]>
1920
*/
2021
class UriSafeTokenGeneratorTest extends TestCase
2122
{
23+
use ForwardCompatTestTrait;
24+
2225
const ENTROPY = 1000;
2326

2427
/**
@@ -33,17 +36,17 @@ class UriSafeTokenGeneratorTest extends TestCase
3336
*/
3437
private $generator;
3538

36-
public static function setUpBeforeClass()
39+
private static function doSetUpBeforeClass()
3740
{
3841
self::$bytes = base64_decode('aMf+Tct/RLn2WQ==');
3942
}
4043

41-
protected function setUp()
44+
private function doSetUp()
4245
{
4346
$this->generator = new UriSafeTokenGenerator(self::ENTROPY);
4447
}
4548

46-
protected function tearDown()
49+
private function doTearDown()
4750
{
4851
$this->generator = null;
4952
}

Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Csrf\Tests\TokenStorage;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage;
1617

1718
/**
@@ -22,14 +23,16 @@
2223
*/
2324
class NativeSessionTokenStorageTest extends TestCase
2425
{
26+
use ForwardCompatTestTrait;
27+
2528
const SESSION_NAMESPACE = 'foobar';
2629

2730
/**
2831
* @var NativeSessionTokenStorage
2932
*/
3033
private $storage;
3134

32-
protected function setUp()
35+
private function doSetUp()
3336
{
3437
$_SESSION = [];
3538

Csrf/Tests/TokenStorage/SessionTokenStorageTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Csrf\Tests\TokenStorage;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\HttpFoundation\Session\Session;
1617
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1718
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
@@ -21,6 +22,8 @@
2122
*/
2223
class SessionTokenStorageTest extends TestCase
2324
{
25+
use ForwardCompatTestTrait;
26+
2427
const SESSION_NAMESPACE = 'foobar';
2528

2629
/**
@@ -33,7 +36,7 @@ class SessionTokenStorageTest extends TestCase
3336
*/
3437
private $storage;
3538

36-
protected function setUp()
39+
private function doSetUp()
3740
{
3841
$this->session = new Session(new MockArraySessionStorage());
3942
$this->storage = new SessionTokenStorage($this->session, self::SESSION_NAMESPACE);

Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Guard\Tests\Authenticator;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1718
use Symfony\Component\Security\Core\User\UserInterface;
@@ -23,6 +24,8 @@
2324
*/
2425
class FormLoginAuthenticatorTest extends TestCase
2526
{
27+
use ForwardCompatTestTrait;
28+
2629
private $requestWithoutSession;
2730
private $requestWithSession;
2831
private $authenticator;
@@ -127,7 +130,7 @@ public function testStartWithSession()
127130
$this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl());
128131
}
129132

130-
protected function setUp()
133+
private function doSetUp()
131134
{
132135
$this->requestWithoutSession = new Request([], [], [], [], [], []);
133136
$this->requestWithSession = new Request([], [], [], [], [], []);

Guard/Tests/Firewall/GuardAuthenticationListenerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Guard\Tests\Firewall;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -28,6 +29,8 @@
2829
*/
2930
class GuardAuthenticationListenerTest extends TestCase
3031
{
32+
use ForwardCompatTestTrait;
33+
3134
private $authenticationManager;
3235
private $guardAuthenticatorHandler;
3336
private $event;
@@ -420,7 +423,7 @@ public function testReturnNullFromGetCredentialsTriggersForAbstractGuardAuthenti
420423
$listener->handle($this->event);
421424
}
422425

423-
protected function setUp()
426+
private function doSetUp()
424427
{
425428
$this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')
426429
->disableOriginalConstructor()
@@ -445,7 +448,7 @@ protected function setUp()
445448
$this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock();
446449
}
447450

448-
protected function tearDown()
451+
private function doTearDown()
449452
{
450453
$this->authenticationManager = null;
451454
$this->guardAuthenticatorHandler = null;

0 commit comments

Comments
 (0)