Skip to content
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 @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.1', '8.2', '8.3' ]
php-versions: [ '8.1', '8.2', '8.3', '8.4' ]

steps:
- name: Checkout
Expand Down
4 changes: 3 additions & 1 deletion Common/UserAwareComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ final protected function getImpersonatingUser()
public function getUsername()
{
$user = $this->getUser();

if (empty($user)) {
return $this->getAnonymousUserName();
}
if (method_exists($user, 'getUserIdentifier')) {
return $user->getUserIdentifier();
}

return $user->getUsername();
}
Expand Down
26 changes: 26 additions & 0 deletions Tests/Common/UserAwareComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,32 @@ public function testShouldReturnImpersonatingUserIfUserHavePreviousAdminRole()
$this->assertEquals(1, $user->getId());
}

public function testGetUsernameWithLegacyUserHavingOnlyGetUsername()
{
$legacyUser = new class {
public function getUsername()
{
return 'legacy-user';
}
};

$component = new class($legacyUser) extends DummyUserAwareComponent {
private $mockUser;

public function __construct($mockUser)
{
$this->mockUser = $mockUser;
}

public function getUser()
{
return $this->mockUser;
}
};

$this->assertEquals('legacy-user', $component->getUsername());
}

private function mockSecurityAuthChecker($isGranted = false)
{
$this->authChecker->expects($this->once())
Expand Down
34 changes: 23 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
"name": "xiidea/easy-audit",
"type": "symfony-bundle",
"description": "A Symfony Bundle To Log Selective Events. It is easy to configure and easy to customize for your need",
"keywords": ["Event Log", "Audit Log", "Symfony2", "Symfony3", "Symfony4", "Symfony5", "Symfony6", "Audit trail", "PSR-3"],
"keywords": [
"Event Log",
"Audit Log",
"Symfony2",
"Symfony3",
"Symfony4",
"Symfony5",
"Symfony6",
"Audit trail",
"PSR-3"
],
"license": "MIT",
"homepage": "http://xiidea.github.io/EasyAuditBundle/",
"authors": [
Expand All @@ -23,29 +33,31 @@
"require": {
"php": ">=8.1",
"psr/log": "^1|^2|^3",
"symfony/framework-bundle": ">=5.4 <8.0",
"symfony/security-bundle": ">=5.4 <8.0"
"symfony/framework-bundle": ">=5.4 <9.0",
"symfony/security-bundle": ">=5.4 <9.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"php-coveralls/php-coveralls": "^2.1",
"doctrine/common": ">=2.2 <4.0",
"symfony/test-pack": "^1.0",
"symfony/twig-bundle": ">=5.4 <8.0",
"symfony/form": ">=5.4 <8.0",
"symfony/validator": ">=5.4 <8.0"
"symfony/twig-bundle": ">=5.4 <9.0",
"symfony/form": ">=5.4 <9.0",
"symfony/validator": ">=5.4 <9.0"
},
"autoload": {
"psr-4": {
"Xiidea\\EasyAuditBundle\\": ""
}
"psr-4": {
"Xiidea\\EasyAuditBundle\\": ""
}
},
"autoload-dev": {
"psr-4": { "Xiidea\\EasyAuditBundle\\Tests\\": "Tests/" }
"psr-4": {
"Xiidea\\EasyAuditBundle\\Tests\\": "Tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
}
}
}
Loading