1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Mon, 17 Feb 2025 12:08:34 +0100
Subject: Modernize PHPUnit syntax
---
Tests/Dbal/AclProviderBenchmarkTest.php | 5 ++---
Tests/Domain/AuditLoggerTest.php | 4 ++++
Tests/Domain/DoctrineAclCacheTest.php | 2 ++
Tests/Domain/ObjectIdentityTest.php | 2 ++
Tests/Domain/PermissionGrantingStrategyTest.php | 2 ++
Tests/Domain/RoleSecurityIdentityTest.php | 2 ++
Tests/Domain/SecurityIdentityRetrievalStrategyTest.php | 3 +++
Tests/Domain/UserSecurityIdentityTest.php | 5 ++---
Tests/Permission/MaskBuilderTest.php | 2 ++
Tests/Voter/AclVoterTest.php | 8 ++++++++
10 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/Tests/Dbal/AclProviderBenchmarkTest.php b/Tests/Dbal/AclProviderBenchmarkTest.php
index 685031a..70a1b97 100644
--- a/Tests/Dbal/AclProviderBenchmarkTest.php
+++ b/Tests/Dbal/AclProviderBenchmarkTest.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\Security\Acl\Tests\Dbal;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Dbal\AclProvider;
use Symfony\Component\Security\Acl\Dbal\Schema;
@@ -52,9 +53,7 @@ class AclProviderBenchmarkTest extends TestCase
$this->connection = null;
}
- /**
- * @group nophpunit11
- */
+ #[Group('nophpunit11')]
public function testFindAcls()
{
// $this->generateTestData();
diff --git a/Tests/Domain/AuditLoggerTest.php b/Tests/Domain/AuditLoggerTest.php
index 95b1f4a..9f3162b 100644
--- a/Tests/Domain/AuditLoggerTest.php
+++ b/Tests/Domain/AuditLoggerTest.php
@@ -11,6 +11,8 @@
namespace Symfony\Component\Security\Acl\Tests\Domain;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\AuditLogger;
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAuditableEntryInterface;
@@ -20,6 +22,8 @@ class AuditLoggerTest extends TestCase
/**
* @dataProvider getTestLogData
*/
+ #[DataProvider('getTestLogData')]
+ #[Group('nophpunit11')]
public function testLogIfNeeded($granting, $audit)
{
$logger = $this->getLogger();
diff --git a/Tests/Domain/DoctrineAclCacheTest.php b/Tests/Domain/DoctrineAclCacheTest.php
index 1d2c6a6..036989d 100644
--- a/Tests/Domain/DoctrineAclCacheTest.php
+++ b/Tests/Domain/DoctrineAclCacheTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Acl\Tests\Domain;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Security\Acl\Domain\Acl;
@@ -27,6 +28,7 @@ class DoctrineAclCacheTest extends TestCase
/**
* @dataProvider getEmptyValue
*/
+ #[DataProvider('getEmptyValue')]
public function testConstructorDoesNotAcceptEmptyPrefix($empty)
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/Tests/Domain/ObjectIdentityTest.php b/Tests/Domain/ObjectIdentityTest.php
index 3a86db3..698a3d7 100644
--- a/Tests/Domain/ObjectIdentityTest.php
+++ b/Tests/Domain/ObjectIdentityTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Domain
{
+ use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Model\DomainObjectInterface;
@@ -88,6 +89,7 @@ namespace Symfony\Component\Security\Acl\Tests\Domain
/**
* @dataProvider getCompareData
*/
+ #[DataProvider('getCompareData')]
public function testEquals($oid1, $oid2, $equal)
{
if ($equal) {
diff --git a/Tests/Domain/PermissionGrantingStrategyTest.php b/Tests/Domain/PermissionGrantingStrategyTest.php
index d7225e2..6394fee 100644
--- a/Tests/Domain/PermissionGrantingStrategyTest.php
+++ b/Tests/Domain/PermissionGrantingStrategyTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Domain;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\Acl;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
@@ -142,6 +143,7 @@ class PermissionGrantingStrategyTest extends TestCase
/**
* @dataProvider getAllStrategyTests
*/
+ #[DataProvider('getAllStrategyTests')]
public function testIsGrantedStrategies($maskStrategy, $aceMask, $requiredMask, $result)
{
$strategy = new PermissionGrantingStrategy();
diff --git a/Tests/Domain/RoleSecurityIdentityTest.php b/Tests/Domain/RoleSecurityIdentityTest.php
index c82f6c3..6a912d0 100644
--- a/Tests/Domain/RoleSecurityIdentityTest.php
+++ b/Tests/Domain/RoleSecurityIdentityTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Domain;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
@@ -28,6 +29,7 @@ class RoleSecurityIdentityTest extends TestCase
/**
* @dataProvider getCompareData
*/
+ #[DataProvider('getCompareData')]
public function testEquals(RoleSecurityIdentity $id1, SecurityIdentityInterface $id2, bool $equal)
{
if ($equal) {
diff --git a/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php b/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php
index cc0ed6f..0791198 100644
--- a/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php
+++ b/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Domain;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
use Symfony\Component\Security\Acl\Domain\SecurityIdentityRetrievalStrategy;
@@ -29,6 +30,7 @@ class SecurityIdentityRetrievalStrategyTest extends TestCase
/**
* @dataProvider getSecurityIdentityRetrievalTests
*/
+ #[DataProvider('getSecurityIdentityRetrievalTests')]
public function testGetSecurityIdentities($user, array $roles, string $authenticationStatus, array $sids)
{
$token = class_exists(NullToken::class) ? new NullToken() : new AnonymousToken('', '');
@@ -74,6 +76,7 @@ class SecurityIdentityRetrievalStrategyTest extends TestCase
*
* @dataProvider getDeprecatedSecurityIdentityRetrievalTests
*/
+ #[DataProvider('getDeprecatedSecurityIdentityRetrievalTests')]
public function testDeprecatedGetSecurityIdentities($user, array $roles, string $authenticationStatus, array $sids)
{
if (method_exists(AuthenticationTrustResolverInterface::class, 'isAuthenticated')) {
diff --git a/Tests/Domain/UserSecurityIdentityTest.php b/Tests/Domain/UserSecurityIdentityTest.php
index 6b8d529..a4eee0d 100644
--- a/Tests/Domain/UserSecurityIdentityTest.php
+++ b/Tests/Domain/UserSecurityIdentityTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Domain;
+use PHPUnit\Framework\Attributes\Group;
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
@@ -36,9 +37,7 @@ class UserSecurityIdentityTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain\Foo', $id->getClass());
}
- /**
- * @group nophpunit11
- */
+ #[Group('nophpunit11')]
public function testEquals(UserSecurityIdentity $id1, SecurityIdentityInterface $id2, bool $equal)
{
$this->assertSame($equal, $id1->equals($id2));
diff --git a/Tests/Permission/MaskBuilderTest.php b/Tests/Permission/MaskBuilderTest.php
index 9203fb6..4959755 100644
--- a/Tests/Permission/MaskBuilderTest.php
+++ b/Tests/Permission/MaskBuilderTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Permission;
+use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Security\Acl\Permission\MaskBuilder;
class MaskBuilderTest extends \PHPUnit\Framework\TestCase
@@ -18,6 +19,7 @@ class MaskBuilderTest extends \PHPUnit\Framework\TestCase
/**
* @dataProvider getInvalidConstructorData
*/
+ #[DataProvider('getInvalidConstructorData')]
public function testConstructorWithNonInteger($invalidMask)
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/Tests/Voter/AclVoterTest.php b/Tests/Voter/AclVoterTest.php
index c652ca4..fc45b67 100644
--- a/Tests/Voter/AclVoterTest.php
+++ b/Tests/Voter/AclVoterTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Acl\Tests\Voter;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
@@ -32,6 +33,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getSupportsAttributeTests
*/
+ #[DataProvider('getSupportsAttributeTests')]
public function testSupportsAttribute($attribute, $supported)
{
[$voter, , $permissionMap] = $this->getVoter(true, false);
@@ -49,6 +51,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getSupportsAttributeNonStringTests
*/
+ #[DataProvider('getSupportsAttributeNonStringTests')]
public function testSupportsAttributeNonString($attribute)
{
[$voter] = $this->getVoter(true, false);
@@ -77,6 +80,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getSupportsClassTests
*/
+ #[DataProvider('getSupportsClassTests')]
public function testSupportsClass($class)
{
[$voter] = $this->getVoter();
@@ -108,6 +112,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getTrueFalseTests
*/
+ #[DataProvider('getTrueFalseTests')]
public function testVoteWhenNoObjectIsPassed($allowIfObjectIdentityUnavailable)
{
[$voter, , $permissionMap] = $this->getVoter($allowIfObjectIdentityUnavailable);
@@ -129,6 +134,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getTrueFalseTests
*/
+ #[DataProvider('getTrueFalseTests')]
public function testVoteWhenOidStrategyReturnsNull($allowIfUnavailable)
{
[$voter, , $permissionMap, $oidStrategy] = $this->getVoter($allowIfUnavailable);
@@ -193,6 +199,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getTrueFalseTests
*/
+ #[DataProvider('getTrueFalseTests')]
public function testVoteGrantsAccess($grant)
{
[$voter, $provider, $permissionMap, $oidStrategy, $sidStrategy] = $this->getVoter();
@@ -282,6 +289,7 @@ class AclVoterTest extends TestCase
/**
* @dataProvider getTrueFalseTests
*/
+ #[DataProvider('getTrueFalseTests')]
public function testVoteGrantsFieldAccess($grant)
{
[$voter, $provider, $permissionMap, $oidStrategy, $sidStrategy] = $this->getVoter();
|