diff --git a/Authorization/TraceableAccessDecisionManager.php b/Authorization/TraceableAccessDecisionManager.php index 10299fe5..1f0f30ed 100644 --- a/Authorization/TraceableAccessDecisionManager.php +++ b/Authorization/TraceableAccessDecisionManager.php @@ -38,11 +38,11 @@ public function __construct(AccessDecisionManagerInterface $manager) // The strategy and voters are stored in a private properties of the decorated service if (property_exists($manager, 'strategy')) { - $reflection = new \ReflectionProperty(\get_class($manager), 'strategy'); + $reflection = new \ReflectionProperty($manager::class, 'strategy'); $this->strategy = $reflection->getValue($manager); } if (property_exists($manager, 'voters')) { - $reflection = new \ReflectionProperty(\get_class($manager), 'voters'); + $reflection = new \ReflectionProperty($manager::class, 'voters'); $this->voters = $reflection->getValue($manager); } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d88a0ce..7ba95c05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,11 @@ CHANGELOG or `LegacyPasswordAuthenticatedUserInterface` instead * `AccessDecisionManager` requires the strategy to be passed as in instance of `AccessDecisionStrategyInterface` +5.4.21 +------ + + * [BC BREAK] `AccessDecisionStrategyTestCase::provideStrategyTests()` is now static + 5.4 --- diff --git a/LICENSE b/LICENSE index 00837045..0138f8f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Test/AccessDecisionStrategyTestCase.php b/Test/AccessDecisionStrategyTestCase.php index a82bf61f..d542588f 100644 --- a/Test/AccessDecisionStrategyTestCase.php +++ b/Test/AccessDecisionStrategyTestCase.php @@ -40,32 +40,41 @@ final public function testDecide(AccessDecisionStrategyInterface $strategy, arra /** * @return iterable */ - abstract public function provideStrategyTests(): iterable; + abstract public static function provideStrategyTests(): iterable; /** * @return VoterInterface[] */ - final protected function getVoters(int $grants, int $denies, int $abstains): array + final protected static function getVoters(int $grants, int $denies, int $abstains): array { $voters = []; for ($i = 0; $i < $grants; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_GRANTED); + $voters[] = static::getVoter(VoterInterface::ACCESS_GRANTED); } for ($i = 0; $i < $denies; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_DENIED); + $voters[] = static::getVoter(VoterInterface::ACCESS_DENIED); } for ($i = 0; $i < $abstains; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_ABSTAIN); + $voters[] = static::getVoter(VoterInterface::ACCESS_ABSTAIN); } return $voters; } - final protected function getVoter(int $vote): VoterInterface + final protected static function getVoter(int $vote): VoterInterface { - $voter = $this->createMock(VoterInterface::class); - $voter->method('vote')->willReturn($vote); + return new class($vote) implements VoterInterface { + private $vote; - return $voter; + public function __construct(int $vote) + { + $this->vote = $vote; + } + + public function vote(TokenInterface $token, $subject, array $attributes): int + { + return $this->vote; + } + }; } } diff --git a/Tests/Authentication/Token/AbstractTokenTest.php b/Tests/Authentication/Token/AbstractTokenTest.php index 056123f6..dc67f22f 100644 --- a/Tests/Authentication/Token/AbstractTokenTest.php +++ b/Tests/Authentication/Token/AbstractTokenTest.php @@ -28,7 +28,7 @@ public function testGetUserIdentifier($user, string $username) $this->assertEquals($username, $token->getUserIdentifier()); } - public function provideUsers() + public static function provideUsers() { yield [new InMemoryUser('fabien', null), 'fabien']; } diff --git a/Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php b/Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php index f8f11d13..1009dab6 100644 --- a/Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php +++ b/Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php @@ -31,7 +31,7 @@ public function testGetSetToken() $request = new Request(); $request->setSession($session); - $requestStack = $this->getMockBuilder(RequestStack::class)->setMethods(['getSession'])->getMock(); + $requestStack = $this->getMockBuilder(RequestStack::class)->onlyMethods(['getSession'])->getMock(); $requestStack->push($request); $requestStack->expects($this->any())->method('getSession')->willReturnCallback(function () use ($session, &$sessionAccess) { ++$sessionAccess; diff --git a/Tests/Authorization/AccessDecisionManagerTest.php b/Tests/Authorization/AccessDecisionManagerTest.php index 7228f5a8..41b772d5 100644 --- a/Tests/Authorization/AccessDecisionManagerTest.php +++ b/Tests/Authorization/AccessDecisionManagerTest.php @@ -118,8 +118,17 @@ public function testCacheableVotersWithMultipleAttributes() $voter ->expects($this->exactly(2)) ->method('supportsAttribute') - ->withConsecutive(['foo'], ['bar']) - ->willReturnOnConsecutiveCalls(false, true); + ->willReturnCallback(function (...$args) { + static $series = [ + [['foo'], false], + [['bar'], true], + ]; + + [$expectedArgs, $return] = array_shift($series); + $this->assertSame($expectedArgs, $args); + + return $return; + }); $voter ->expects($this->once()) ->method('supportsType') @@ -227,30 +236,37 @@ public function testCacheableVotersWithMultipleAttributesAndNonString() $this->assertTrue($manager->decide($token, ['foo', 1337], 'bar', true)); } - protected function getVoters($grants, $denies, $abstains) + protected static function getVoters($grants, $denies, $abstains): array { $voters = []; for ($i = 0; $i < $grants; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_GRANTED); + $voters[] = self::getVoter(VoterInterface::ACCESS_GRANTED); } for ($i = 0; $i < $denies; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_DENIED); + $voters[] = self::getVoter(VoterInterface::ACCESS_DENIED); } for ($i = 0; $i < $abstains; ++$i) { - $voters[] = $this->getVoter(VoterInterface::ACCESS_ABSTAIN); + $voters[] = self::getVoter(VoterInterface::ACCESS_ABSTAIN); } return $voters; } - protected function getVoter($vote) + protected static function getVoter($vote) { - $voter = $this->createMock(VoterInterface::class); - $voter->expects($this->any()) - ->method('vote') - ->willReturn($vote); + return new class($vote) implements VoterInterface { + private $vote; - return $voter; + public function __construct(int $vote) + { + $this->vote = $vote; + } + + public function vote(TokenInterface $token, $subject, array $attributes) + { + return $this->vote; + } + }; } private function getExpectedVoter(int $vote): VoterInterface diff --git a/Tests/Authorization/AuthorizationCheckerTest.php b/Tests/Authorization/AuthorizationCheckerTest.php index 957d9938..254bd978 100644 --- a/Tests/Authorization/AuthorizationCheckerTest.php +++ b/Tests/Authorization/AuthorizationCheckerTest.php @@ -57,7 +57,7 @@ public function testIsGranted($decide) $this->assertSame($decide, $this->authorizationChecker->isGranted('ROLE_FOO')); } - public function isGrantedProvider() + public static function isGrantedProvider() { return [[true], [false]]; } diff --git a/Tests/Authorization/ExpressionLanguageTest.php b/Tests/Authorization/ExpressionLanguageTest.php index e1366732..8cc4810a 100644 --- a/Tests/Authorization/ExpressionLanguageTest.php +++ b/Tests/Authorization/ExpressionLanguageTest.php @@ -44,7 +44,7 @@ public function testIsAuthenticated($token, $expression, $result) $this->assertEquals($result, $expressionLanguage->evaluate($expression, $context)); } - public function provider() + public static function provider() { $roles = ['ROLE_USER', 'ROLE_ADMIN']; $user = new InMemoryUser('username', 'password', $roles); diff --git a/Tests/Authorization/Strategy/AffirmativeStrategyTest.php b/Tests/Authorization/Strategy/AffirmativeStrategyTest.php index 3c9004c7..b467a920 100644 --- a/Tests/Authorization/Strategy/AffirmativeStrategyTest.php +++ b/Tests/Authorization/Strategy/AffirmativeStrategyTest.php @@ -16,17 +16,17 @@ class AffirmativeStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new AffirmativeStrategy(); - yield [$strategy, $this->getVoters(1, 0, 0), true]; - yield [$strategy, $this->getVoters(1, 2, 0), true]; - yield [$strategy, $this->getVoters(0, 1, 0), false]; - yield [$strategy, $this->getVoters(0, 0, 1), false]; + yield [$strategy, self::getVoters(1, 0, 0), true]; + yield [$strategy, self::getVoters(1, 2, 0), true]; + yield [$strategy, self::getVoters(0, 1, 0), false]; + yield [$strategy, self::getVoters(0, 0, 1), false]; $strategy = new AffirmativeStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 1), true]; + yield [$strategy, self::getVoters(0, 0, 1), true]; } } diff --git a/Tests/Authorization/Strategy/ConsensusStrategyTest.php b/Tests/Authorization/Strategy/ConsensusStrategyTest.php index 83adf3ac..bde6fb0d 100644 --- a/Tests/Authorization/Strategy/ConsensusStrategyTest.php +++ b/Tests/Authorization/Strategy/ConsensusStrategyTest.php @@ -16,25 +16,25 @@ class ConsensusStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new ConsensusStrategy(); - yield [$strategy, $this->getVoters(1, 0, 0), true]; - yield [$strategy, $this->getVoters(1, 2, 0), false]; - yield [$strategy, $this->getVoters(2, 1, 0), true]; - yield [$strategy, $this->getVoters(0, 0, 1), false]; + yield [$strategy, self::getVoters(1, 0, 0), true]; + yield [$strategy, self::getVoters(1, 2, 0), false]; + yield [$strategy, self::getVoters(2, 1, 0), true]; + yield [$strategy, self::getVoters(0, 0, 1), false]; - yield [$strategy, $this->getVoters(2, 2, 0), true]; - yield [$strategy, $this->getVoters(2, 2, 1), true]; + yield [$strategy, self::getVoters(2, 2, 0), true]; + yield [$strategy, self::getVoters(2, 2, 1), true]; $strategy = new ConsensusStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 1), true]; + yield [$strategy, self::getVoters(0, 0, 1), true]; $strategy = new ConsensusStrategy(false, false); - yield [$strategy, $this->getVoters(2, 2, 0), false]; - yield [$strategy, $this->getVoters(2, 2, 1), false]; + yield [$strategy, self::getVoters(2, 2, 0), false]; + yield [$strategy, self::getVoters(2, 2, 1), false]; } } diff --git a/Tests/Authorization/Strategy/PriorityStrategyTest.php b/Tests/Authorization/Strategy/PriorityStrategyTest.php index 7cd31842..aef3aaf0 100644 --- a/Tests/Authorization/Strategy/PriorityStrategyTest.php +++ b/Tests/Authorization/Strategy/PriorityStrategyTest.php @@ -17,28 +17,28 @@ class PriorityStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new PriorityStrategy(); yield [$strategy, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_GRANTED), - $this->getVoter(VoterInterface::ACCESS_DENIED), - $this->getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_DENIED), ], true]; yield [$strategy, [ - $this->getVoter(VoterInterface::ACCESS_ABSTAIN), - $this->getVoter(VoterInterface::ACCESS_DENIED), - $this->getVoter(VoterInterface::ACCESS_GRANTED), - $this->getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_ABSTAIN), + self::getVoter(VoterInterface::ACCESS_DENIED), + self::getVoter(VoterInterface::ACCESS_GRANTED), + self::getVoter(VoterInterface::ACCESS_GRANTED), ], false]; - yield [$strategy, $this->getVoters(0, 0, 2), false]; + yield [$strategy, self::getVoters(0, 0, 2), false]; $strategy = new PriorityStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 2), true]; + yield [$strategy, self::getVoters(0, 0, 2), true]; } } diff --git a/Tests/Authorization/Strategy/UnanimousStrategyTest.php b/Tests/Authorization/Strategy/UnanimousStrategyTest.php index 1d49cf4e..e00a50e3 100644 --- a/Tests/Authorization/Strategy/UnanimousStrategyTest.php +++ b/Tests/Authorization/Strategy/UnanimousStrategyTest.php @@ -16,18 +16,18 @@ class UnanimousStrategyTest extends AccessDecisionStrategyTestCase { - public function provideStrategyTests(): iterable + public static function provideStrategyTests(): iterable { $strategy = new UnanimousStrategy(); - yield [$strategy, $this->getVoters(1, 0, 0), true]; - yield [$strategy, $this->getVoters(1, 0, 1), true]; - yield [$strategy, $this->getVoters(1, 1, 0), false]; + yield [$strategy, self::getVoters(1, 0, 0), true]; + yield [$strategy, self::getVoters(1, 0, 1), true]; + yield [$strategy, self::getVoters(1, 1, 0), false]; - yield [$strategy, $this->getVoters(0, 0, 2), false]; + yield [$strategy, self::getVoters(0, 0, 2), false]; $strategy = new UnanimousStrategy(true); - yield [$strategy, $this->getVoters(0, 0, 2), true]; + yield [$strategy, self::getVoters(0, 0, 2), true]; } } diff --git a/Tests/Authorization/TraceableAccessDecisionManagerTest.php b/Tests/Authorization/TraceableAccessDecisionManagerTest.php index c0ba6f11..cefe8dbc 100644 --- a/Tests/Authorization/TraceableAccessDecisionManagerTest.php +++ b/Tests/Authorization/TraceableAccessDecisionManagerTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; +use Symfony\Component\Security\Core\Tests\Fixtures\DummyVoter; class TraceableAccessDecisionManagerTest extends TestCase { @@ -49,10 +50,10 @@ public function testDecideLog(array $expectedLog, array $attributes, $object, ar $this->assertEquals($expectedLog, $adm->getDecisionLog()); } - public function provideObjectsAndLogs(): \Generator + public static function provideObjectsAndLogs(): \Generator { - $voter1 = $this->getMockForAbstractClass(VoterInterface::class); - $voter2 = $this->getMockForAbstractClass(VoterInterface::class); + $voter1 = new DummyVoter(); + $voter2 = new DummyVoter(); yield [ [[ @@ -177,17 +178,17 @@ public function testAccessDecisionManagerCalledByVoter() { $voter1 = $this ->getMockBuilder(VoterInterface::class) - ->setMethods(['vote']) + ->onlyMethods(['vote']) ->getMock(); $voter2 = $this ->getMockBuilder(VoterInterface::class) - ->setMethods(['vote']) + ->onlyMethods(['vote']) ->getMock(); $voter3 = $this ->getMockBuilder(VoterInterface::class) - ->setMethods(['vote']) + ->onlyMethods(['vote']) ->getMock(); $sut = new TraceableAccessDecisionManager(new AccessDecisionManager([$voter1, $voter2, $voter3])); diff --git a/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/Tests/Authorization/Voter/AuthenticatedVoterTest.php index 4d8c067c..88544c08 100644 --- a/Tests/Authorization/Voter/AuthenticatedVoterTest.php +++ b/Tests/Authorization/Voter/AuthenticatedVoterTest.php @@ -33,7 +33,7 @@ public function testVote($authenticated, $attributes, $expected) $this->assertSame($expected, $voter->vote($this->getToken($authenticated), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return [ ['fully', [], VoterInterface::ACCESS_ABSTAIN], @@ -63,7 +63,7 @@ public function testSupportsAttribute(string $attribute, bool $expected) $this->assertSame($expected, $voter->supportsAttribute($attribute)); } - public function provideAttributes() + public static function provideAttributes() { yield [AuthenticatedVoter::IS_AUTHENTICATED_FULLY, true]; yield [AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED, true]; diff --git a/Tests/Authorization/Voter/ExpressionVoterTest.php b/Tests/Authorization/Voter/ExpressionVoterTest.php index a3e51695..369b17f0 100644 --- a/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -32,16 +32,16 @@ public function testVoteWithTokenThatReturnsRoleNames($roles, $attributes, $expe $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles, $tokenExpectsGetRoles), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return [ [[], [], VoterInterface::ACCESS_ABSTAIN, false, false], [[], ['FOO'], VoterInterface::ACCESS_ABSTAIN, false, false], - [[], [$this->createExpression()], VoterInterface::ACCESS_DENIED, true, false], + [[], [self::createExpression()], VoterInterface::ACCESS_DENIED, true, false], - [['ROLE_FOO'], [$this->createExpression(), $this->createExpression()], VoterInterface::ACCESS_GRANTED], - [['ROLE_BAR', 'ROLE_FOO'], [$this->createExpression()], VoterInterface::ACCESS_GRANTED], + [['ROLE_FOO'], [self::createExpression(), self::createExpression()], VoterInterface::ACCESS_GRANTED], + [['ROLE_BAR', 'ROLE_FOO'], [self::createExpression()], VoterInterface::ACCESS_GRANTED], ]; } @@ -81,8 +81,8 @@ protected function createAuthorizationChecker() return $this->createMock(AuthorizationCheckerInterface::class); } - protected function createExpression() + protected static function createExpression() { - return $this->createMock(Expression::class); + return new Expression(''); } } diff --git a/Tests/Authorization/Voter/RoleHierarchyVoterTest.php b/Tests/Authorization/Voter/RoleHierarchyVoterTest.php index 57127007..b811bd74 100644 --- a/Tests/Authorization/Voter/RoleHierarchyVoterTest.php +++ b/Tests/Authorization/Voter/RoleHierarchyVoterTest.php @@ -27,7 +27,7 @@ public function testVoteUsingTokenThatReturnsRoleNames($roles, $attributes, $exp $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return array_merge(parent::getVoteTests(), [ [['ROLE_FOO'], ['ROLE_FOOBAR'], VoterInterface::ACCESS_GRANTED], @@ -44,7 +44,7 @@ public function testVoteWithEmptyHierarchyUsingTokenThatReturnsRoleNames($roles, $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes)); } - public function getVoteWithEmptyHierarchyTests() + public static function getVoteWithEmptyHierarchyTests() { return parent::getVoteTests(); } diff --git a/Tests/Authorization/Voter/RoleVoterTest.php b/Tests/Authorization/Voter/RoleVoterTest.php index c97267ef..dfa05556 100644 --- a/Tests/Authorization/Voter/RoleVoterTest.php +++ b/Tests/Authorization/Voter/RoleVoterTest.php @@ -30,7 +30,7 @@ public function testVoteUsingTokenThatReturnsRoleNames($roles, $attributes, $exp $this->assertSame($expected, $voter->vote($this->getTokenWithRoleNames($roles), null, $attributes)); } - public function getVoteTests() + public static function getVoteTests() { return [ [[], [], VoterInterface::ACCESS_ABSTAIN], @@ -56,7 +56,7 @@ public function testSupportsAttribute(string $prefix, string $attribute, bool $e $this->assertSame($expected, $voter->supportsAttribute($attribute)); } - public function provideAttributes() + public static function provideAttributes() { yield ['ROLE_', 'ROLE_foo', true]; yield ['ROLE_', 'ROLE_', true]; diff --git a/Tests/Authorization/Voter/VoterTest.php b/Tests/Authorization/Voter/VoterTest.php index 4b729d6a..25aff8e1 100644 --- a/Tests/Authorization/Voter/VoterTest.php +++ b/Tests/Authorization/Voter/VoterTest.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->token = $this->createMock(TokenInterface::class); } - public function getTests() + public static function getTests(): array { $voter = new VoterTest_Voter(); $integerVoter = new IntegerVoterTest_Voter(); @@ -41,7 +41,7 @@ public function getTests() [$voter, ['DELETE'], VoterInterface::ACCESS_ABSTAIN, new \stdClass(), 'ACCESS_ABSTAIN if no attribute is supported'], - [$voter, ['EDIT'], VoterInterface::ACCESS_ABSTAIN, $this, 'ACCESS_ABSTAIN if class is not supported'], + [$voter, ['EDIT'], VoterInterface::ACCESS_ABSTAIN, new class() {}, 'ACCESS_ABSTAIN if class is not supported'], [$voter, ['EDIT'], VoterInterface::ACCESS_ABSTAIN, null, 'ACCESS_ABSTAIN if object is null'], diff --git a/Tests/Fixtures/DummyVoter.php b/Tests/Fixtures/DummyVoter.php new file mode 100644 index 00000000..1f923423 --- /dev/null +++ b/Tests/Fixtures/DummyVoter.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Tests\Fixtures; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; + +final class DummyVoter implements VoterInterface +{ + public function vote(TokenInterface $token, $subject, array $attributes): int + { + } +} diff --git a/Tests/Resources/TranslationFilesTest.php b/Tests/Resources/TranslationFilesTest.php index cd96e7e6..5d2a9d14 100644 --- a/Tests/Resources/TranslationFilesTest.php +++ b/Tests/Resources/TranslationFilesTest.php @@ -42,7 +42,7 @@ public function testTranslationFileIsValidWithoutEntityLoader($filePath) $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message')))); } - public function provideTranslationFiles() + public static function provideTranslationFiles() { return array_map( function ($filePath) { return (array) $filePath; }, diff --git a/Tests/SecurityTest.php b/Tests/SecurityTest.php index 63eca289..00436895 100644 --- a/Tests/SecurityTest.php +++ b/Tests/SecurityTest.php @@ -61,7 +61,7 @@ public function testGetUser($userInToken, $expectedUser) $this->assertSame($expectedUser, $security->getUser()); } - public function getUserTests() + public static function getUserTests() { yield [null, null]; diff --git a/Tests/Validator/Constraints/UserPasswordTest.php b/Tests/Validator/Constraints/UserPasswordTest.php index 95763021..fae450b6 100644 --- a/Tests/Validator/Constraints/UserPasswordTest.php +++ b/Tests/Validator/Constraints/UserPasswordTest.php @@ -33,7 +33,7 @@ public function testValidatedByService(UserPassword $constraint) self::assertSame('my_service', $constraint->validatedBy()); } - public function provideServiceValidatedConstraints(): iterable + public static function provideServiceValidatedConstraints(): iterable { yield 'Doctrine style' => [new UserPassword(['service' => 'my_service'])]; diff --git a/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/Tests/Validator/Constraints/UserPasswordValidatorTestCase.php similarity index 96% rename from Tests/Validator/Constraints/UserPasswordValidatorTest.php rename to Tests/Validator/Constraints/UserPasswordValidatorTestCase.php index d7c63792..53455080 100644 --- a/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/Tests/Validator/Constraints/UserPasswordValidatorTestCase.php @@ -25,7 +25,7 @@ /** * @author Bernhard Schussek */ -abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase +abstract class UserPasswordValidatorTestCase extends ConstraintValidatorTestCase { private const PASSWORD = 's3Cr3t'; private const SALT = '^S4lt$'; @@ -91,7 +91,7 @@ public function testPasswordIsNotValid(UserPassword $constraint) ->assertRaised(); } - public function provideConstraints(): iterable + public static function provideConstraints(): iterable { yield 'Doctrine style' => [new UserPassword(['message' => 'myMessage'])]; @@ -113,7 +113,7 @@ public function testEmptyPasswordsAreNotValid($password) ->assertRaised(); } - public function emptyPasswordData() + public static function emptyPasswordData() { return [ [null],