Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+75 -78
View File
@@ -11,36 +11,33 @@
namespace Symfony\Component\Security\Acl\Tests\Dbal;
use Symfony\Component\Security\Acl\Dbal\AclProvider;
use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Dbal\Schema;
use Doctrine\DBAL\DriverManager;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Dbal\AclProvider;
use Symfony\Component\Security\Acl\Dbal\Schema;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy;
/**
* @requires extension pdo_sqlite
*/
class AclProviderTest extends \PHPUnit_Framework_TestCase
class AclProviderTest extends TestCase
{
protected $con;
protected $insertClassStmt;
protected $insertEntryStmt;
protected $insertOidStmt;
protected $insertOidAncestorStmt;
protected $insertSidStmt;
private $connection;
/**
* @expectedException \Symfony\Component\Security\Acl\Exception\AclNotFoundException
* @expectedMessage There is no ACL for the given object identity.
*/
public function testFindAclThrowsExceptionWhenNoAclExists()
{
$this->expectException(\Symfony\Component\Security\Acl\Exception\AclNotFoundException::class);
$this->getProvider()->findAcl(new ObjectIdentity('foo', 'foo'));
}
public function testFindAclsThrowsExceptionUnlessAnACLIsFoundForEveryOID()
{
$oids = array();
$oids = [];
$oids[] = new ObjectIdentity('1', 'foo');
$oids[] = new ObjectIdentity('foo', 'foo');
@@ -60,7 +57,7 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
public function testFindAcls()
{
$oids = array();
$oids = [];
$oids[] = new ObjectIdentity('1', 'foo');
$oids[] = new ObjectIdentity('2', 'foo');
@@ -77,7 +74,7 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
public function testFindAclsWithDifferentTypes()
{
$oids = array();
$oids = [];
$oids[] = new ObjectIdentity('123', 'Bundle\SomeVendor\MyBundle\Entity\SomeEntity');
$oids[] = new ObjectIdentity('123', 'Bundle\MyBundle\Entity\AnotherEntity');
@@ -142,49 +139,49 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('SomeClass', $sid->getClass());
}
protected function setUp()
protected function setUp(): void
{
$this->con = DriverManager::getConnection(array(
$this->connection = DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'memory' => true,
));
]);
// import the schema
$schema = new Schema($options = $this->getOptions());
foreach ($schema->toSql($this->con->getDatabasePlatform()) as $sql) {
$this->con->exec($sql);
$schema = new Schema($this->getOptions());
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->executeStatement($sql);
}
// populate the schema with some test data
$this->insertClassStmt = $this->con->prepare('INSERT INTO acl_classes (id, class_type) VALUES (?, ?)');
$insertClassStmt = $this->connection->prepare('INSERT INTO acl_classes (id, class_type) VALUES (?, ?)');
foreach ($this->getClassData() as $data) {
$this->insertClassStmt->execute($data);
$insertClassStmt->executeStatement($data);
}
$this->insertSidStmt = $this->con->prepare('INSERT INTO acl_security_identities (id, identifier, username) VALUES (?, ?, ?)');
$insertSidStmt = $this->connection->prepare('INSERT INTO acl_security_identities (id, identifier, username) VALUES (?, ?, ?)');
foreach ($this->getSidData() as $data) {
$this->insertSidStmt->execute($data);
$insertSidStmt->executeStatement($data);
}
$this->insertOidStmt = $this->con->prepare('INSERT INTO acl_object_identities (id, class_id, object_identifier, parent_object_identity_id, entries_inheriting) VALUES (?, ?, ?, ?, ?)');
$insertOidStmt = $this->connection->prepare('INSERT INTO acl_object_identities (id, class_id, object_identifier, parent_object_identity_id, entries_inheriting) VALUES (?, ?, ?, ?, ?)');
foreach ($this->getOidData() as $data) {
$this->insertOidStmt->execute($data);
$insertOidStmt->executeStatement($data);
}
$this->insertEntryStmt = $this->con->prepare('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
$insertEntryStmt = $this->connection->prepare('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
foreach ($this->getEntryData() as $data) {
$this->insertEntryStmt->execute($data);
$insertEntryStmt->executeStatement($data);
}
$this->insertOidAncestorStmt = $this->con->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)');
$insertOidAncestorStmt = $this->connection->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)');
foreach ($this->getOidAncestorData() as $data) {
$this->insertOidAncestorStmt->execute($data);
$insertOidAncestorStmt->executeStatement($data);
}
}
protected function tearDown()
protected function tearDown(): void
{
$this->con = null;
$this->connection = null;
}
protected function getField($object, $field)
@@ -198,83 +195,83 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
protected function getEntryData()
{
// id, cid, oid, field, order, sid, mask, granting, strategy, a success, a failure
return array(
array(1, 1, 1, null, 0, 1, 1, 1, 'all', 1, 1),
array(2, 1, 1, null, 1, 2, 1 << 2 | 1 << 1, 0, 'any', 0, 0),
array(3, 3, 4, null, 0, 1, 2, 1, 'all', 1, 1),
array(4, 3, 4, null, 2, 2, 1, 1, 'all', 1, 1),
array(5, 3, 4, null, 1, 3, 1, 1, 'all', 1, 1),
);
return [
[1, 1, 1, null, 0, 1, 1, 1, 'all', 1, 1],
[2, 1, 1, null, 1, 2, 1 << 2 | 1 << 1, 0, 'any', 0, 0],
[3, 3, 4, null, 0, 1, 2, 1, 'all', 1, 1],
[4, 3, 4, null, 2, 2, 1, 1, 'all', 1, 1],
[5, 3, 4, null, 1, 3, 1, 1, 'all', 1, 1],
];
}
protected function getOidData()
{
// id, cid, oid, parent_oid, entries_inheriting
return array(
array(1, 1, '123', null, 1),
array(2, 2, '123', 1, 1),
array(3, 2, 'i:3:123', 1, 1),
array(4, 3, '1', 2, 1),
array(5, 3, '2', 2, 1),
);
return [
[1, 1, '123', null, 1],
[2, 2, '123', 1, 1],
[3, 2, 'i:3:123', 1, 1],
[4, 3, '1', 2, 1],
[5, 3, '2', 2, 1],
];
}
protected function getOidAncestorData()
{
return array(
array(1, 1),
array(2, 1),
array(2, 2),
array(3, 1),
array(3, 3),
array(4, 2),
array(4, 1),
array(4, 4),
array(5, 2),
array(5, 1),
array(5, 5),
);
return [
[1, 1],
[2, 1],
[2, 2],
[3, 1],
[3, 3],
[4, 2],
[4, 1],
[4, 4],
[5, 2],
[5, 1],
[5, 5],
];
}
protected function getSidData()
{
return array(
array(1, 'SomeClass-john.doe', 1),
array(2, 'MyClass-john.doe@foo.com', 1),
array(3, 'FooClass-123', 1),
array(4, 'MooClass-ROLE_USER', 1),
array(5, 'ROLE_USER', 0),
array(6, 'IS_AUTHENTICATED_FULLY', 0),
);
return [
[1, 'SomeClass-john.doe', 1],
[2, 'MyClass-john.doe@foo.com', 1],
[3, 'FooClass-123', 1],
[4, 'MooClass-ROLE_USER', 1],
[5, 'ROLE_USER', 0],
[6, 'IS_AUTHENTICATED_FULLY', 0],
];
}
protected function getClassData()
{
return array(
array(1, 'Bundle\SomeVendor\MyBundle\Entity\SomeEntity'),
array(2, 'Bundle\MyBundle\Entity\AnotherEntity'),
array(3, 'foo'),
);
return [
[1, 'Bundle\SomeVendor\MyBundle\Entity\SomeEntity'],
[2, 'Bundle\MyBundle\Entity\AnotherEntity'],
[3, 'foo'],
];
}
protected function getOptions()
{
return array(
return [
'oid_table_name' => 'acl_object_identities',
'oid_ancestors_table_name' => 'acl_object_identity_ancestors',
'class_table_name' => 'acl_classes',
'sid_table_name' => 'acl_security_identities',
'entry_table_name' => 'acl_entries',
);
];
}
protected function getStrategy()
protected function getStrategy(): PermissionGrantingStrategy
{
return new PermissionGrantingStrategy();
}
protected function getProvider()
protected function getProvider(): AclProvider
{
return new AclProvider($this->con, $this->getStrategy(), $this->getOptions());
return new AclProvider($this->connection, $this->getStrategy(), $this->getOptions());
}
}