Skip to content

Fix deprecations triggered by PHP 8.1 #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2.5', '7.3', '7.4', '8.0']
php: ['7.2.5', '7.3', '7.4', '8.0', '8.1']
include:
- php: '7.4'
deps: lowest
Expand Down
10 changes: 7 additions & 3 deletions Tests/Domain/AuditLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

namespace Symfony\Component\Security\Acl\Tests\Domain;

class AuditLoggerTest extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\AuditLogger;
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAuditableEntryInterface;

class AuditLoggerTest extends TestCase
{
/**
* @dataProvider getTestLogData
Expand Down Expand Up @@ -73,11 +77,11 @@ public function getTestLogData()

protected function getEntry()
{
return $this->createMock('Symfony\Component\Security\Acl\Model\AuditableEntryInterface');
return $this->createMock(SerializableAuditableEntryInterface::class);
}

protected function getLogger()
{
return $this->getMockForAbstractClass('Symfony\Component\Security\Acl\Domain\AuditLogger');
return $this->getMockForAbstractClass(AuditLogger::class);
}
}
11 changes: 7 additions & 4 deletions Tests/Domain/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

namespace Symfony\Component\Security\Acl\Tests\Domain;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\Entry;
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAclInterface;

class EntryTest extends \PHPUnit\Framework\TestCase
class EntryTest extends TestCase
{
public function testConstructor()
{
Expand Down Expand Up @@ -77,7 +80,7 @@ public function testSerializeUnserialize()
$uAce = unserialize($serialized);

$this->assertNull($uAce->getAcl());
$this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity());
$this->assertInstanceOf(SecurityIdentityInterface::class, $uAce->getSecurityIdentity());
$this->assertEquals($ace->getId(), $uAce->getId());
$this->assertEquals($ace->getMask(), $uAce->getMask());
$this->assertEquals($ace->getStrategy(), $uAce->getStrategy());
Expand Down Expand Up @@ -109,11 +112,11 @@ protected function getAce($acl = null, $sid = null)

protected function getAcl()
{
return $this->createMock('Symfony\Component\Security\Acl\Model\AclInterface');
return $this->createMock(SerializableAclInterface::class);
}

protected function getSid()
{
return $this->createMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
return $this->createMock(SecurityIdentityInterface::class);
}
}
10 changes: 6 additions & 4 deletions Tests/Domain/FieldEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

namespace Symfony\Component\Security\Acl\Tests\Domain;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Acl\Domain\FieldEntry;
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAclInterface;

class FieldEntryTest extends \PHPUnit\Framework\TestCase
class FieldEntryTest extends TestCase
{
public function testConstructor()
{
Expand All @@ -31,7 +33,7 @@ public function testSerializeUnserialize()
$uAce = unserialize($serialized);

$this->assertNull($uAce->getAcl());
$this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity());
$this->assertInstanceOf(SecurityIdentityInterface::class, $uAce->getSecurityIdentity());
$this->assertEquals($ace->getId(), $uAce->getId());
$this->assertEquals($ace->getField(), $uAce->getField());
$this->assertEquals($ace->getMask(), $uAce->getMask());
Expand Down Expand Up @@ -86,11 +88,11 @@ protected function getAce($acl = null, $sid = null)

protected function getAcl()
{
return $this->createMock('Symfony\Component\Security\Acl\Model\AclInterface');
return $this->createMock(SerializableAclInterface::class);
}

protected function getSid()
{
return $this->createMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
return $this->createMock(SecurityIdentityInterface::class);
}
}
12 changes: 12 additions & 0 deletions Tests/Fixtures/SerializableAclInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Symfony\Component\Security\Acl\Tests\Fixtures;

use Symfony\Component\Security\Acl\Model\AclInterface;

interface SerializableAclInterface extends AclInterface
{
public function __serialize(): array;

public function __unserialize(array $data): void;
}
12 changes: 12 additions & 0 deletions Tests/Fixtures/SerializableAuditableEntryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Symfony\Component\Security\Acl\Tests\Fixtures;

use Symfony\Component\Security\Acl\Model\AuditableEntryInterface;

interface SerializableAuditableEntryInterface extends AuditableEntryInterface
{
public function __serialize(): array;

public function __unserialize(array $data): void;
}
12 changes: 6 additions & 6 deletions Tests/Voter/AclVoterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
use Symfony\Component\Security\Acl\Exception\NoAceFoundException;
use Symfony\Component\Security\Acl\Model\AclInterface;
use Symfony\Component\Security\Acl\Model\AclProviderInterface;
use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface;
use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface;
use Symfony\Component\Security\Acl\Permission\PermissionMapInterface;
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAclInterface;
use Symfony\Component\Security\Acl\Voter\AclVoter;
use Symfony\Component\Security\Acl\Voter\FieldVote;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
Expand Down Expand Up @@ -220,7 +220,7 @@ public function testVoteGrantsAccess($grant)
->expects($this->once())
->method('findAcl')
->with($this->equalTo($oid), $this->equalTo($sids))
->willReturn($acl = $this->createMock(AclInterface::class))
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
;

$acl
Expand Down Expand Up @@ -266,7 +266,7 @@ public function testVoteNoAceFound()
->expects($this->once())
->method('findAcl')
->with($this->equalTo($oid), $this->equalTo($sids))
->willReturn($acl = $this->createMock(AclInterface::class))
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
;

$acl
Expand Down Expand Up @@ -309,7 +309,7 @@ public function testVoteGrantsFieldAccess($grant)
->expects($this->once())
->method('findAcl')
->with($this->equalTo($oid), $this->equalTo($sids))
->willReturn($acl = $this->createMock(AclInterface::class))
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
;

$acl
Expand Down Expand Up @@ -355,7 +355,7 @@ public function testVoteNoFieldAceFound()
->expects($this->once())
->method('findAcl')
->with($this->equalTo($oid), $this->equalTo($sids))
->willReturn($acl = $this->createMock(AclInterface::class))
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
;

$acl
Expand Down Expand Up @@ -396,7 +396,7 @@ public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObje
->expects($this->once())
->method('findAcl')
->with($this->equalTo($oid), $this->equalTo($sids))
->willReturn($acl = $this->createMock(AclInterface::class))
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
;

$acl
Expand Down