Skip to content

Commit 3cbe1ef

Browse files
committed
minor #68 Fix risky tests and deprecation warnings (derrabus)
This PR was merged into the 3.x-dev branch. Discussion ---------- Fix risky tests and deprecation warnings This PR fixes the two risky tests and should (hopefully) give us a green CI. The two tests in question were added in symfony/symfony#9485. As far as I read the PR, the tests should ensure that no exception is thrown. But because they don't assert anything, modern PHPUnit versions would flag the tests as risky. I avoid this issue by bumping the asserion count at the end of each test. Commits ------- 6fd230c Fix risky tests and deprecation warnings
2 parents ed561d1 + 6fd230c commit 3cbe1ef

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Tests/Dbal/MutableAclProviderTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\DBAL\Connection;
1515
use Doctrine\DBAL\DriverManager;
16+
use PHPUnit\Framework\TestCase;
1617
use Symfony\Component\Security\Acl\Dbal\AclProvider;
1718
use Symfony\Component\Security\Acl\Dbal\MutableAclProvider;
1819
use Symfony\Component\Security\Acl\Dbal\Schema;
@@ -31,7 +32,7 @@
3132
/**
3233
* @requires extension pdo_sqlite
3334
*/
34-
class MutableAclProviderTest extends \PHPUnit\Framework\TestCase
35+
class MutableAclProviderTest extends TestCase
3536
{
3637
protected $con;
3738

@@ -383,6 +384,9 @@ public function testUpdateAclInsertingMultipleObjectFieldAcesThrowsDBConstraintV
383384
$acl = $provider->findAcl($oid);
384385
$acl->insertObjectFieldAce($fieldName, $sid3, 4);
385386
$provider->updateAcl($acl);
387+
388+
$acls = $provider->findAcl($oid);
389+
$this->assertCount(3, $acls->getObjectFieldAces($fieldName));
386390
}
387391

388392
public function testUpdateAclDeletingObjectFieldAcesThrowsDBConstraintViolations()
@@ -409,6 +413,9 @@ public function testUpdateAclDeletingObjectFieldAcesThrowsDBConstraintViolations
409413
$acl = $provider->findAcl($oid);
410414
$acl->insertObjectFieldAce($fieldName, $sid3, 4);
411415
$provider->updateAcl($acl);
416+
417+
$acls = $provider->findAcl($oid);
418+
$this->assertCount(2, $acls->getObjectFieldAces($fieldName));
412419
}
413420

414421
public function testUpdateUserSecurityIdentity()

Tests/Domain/RoleSecurityIdentityTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public function testConstructor()
2424
$this->assertEquals('ROLE_FOO', $id->getRole());
2525
}
2626

27+
/**
28+
* @group legacy
29+
*/
2730
public function testConstructorWithRoleInstance()
2831
{
2932
if (!class_exists(\Symfony\Component\Security\Core\Role\Role::class)) {

Tests/Domain/SecurityIdentityRetrievalStrategyTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111

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

14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
1516
use Symfony\Component\Security\Acl\Domain\SecurityIdentityRetrievalStrategy;
1617
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
18+
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
1719
use Symfony\Component\Security\Core\Role\Role;
1820
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
19-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2021
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
2122
use Symfony\Component\Security\Core\User\UserInterface;
2223

23-
class SecurityIdentityRetrievalStrategyTest extends \PHPUnit\Framework\TestCase
24+
class SecurityIdentityRetrievalStrategyTest extends TestCase
2425
{
2526
/**
2627
* @dataProvider getSecurityIdentityRetrievalTests
@@ -37,7 +38,7 @@ public function testGetSecurityIdentities($user, array $roles, $authenticationSt
3738
$class = 'MyCustomTokenImpl';
3839
}
3940

40-
$token = $this->getMockBuilder(TokenInterface::class)
41+
$token = $this->getMockBuilder(AbstractToken::class)
4142
->setMockClassName($class)
4243
->getMock();
4344
}

0 commit comments

Comments
 (0)