diff options
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 13 | ||||
-rw-r--r-- | lib/private/Accounts/Hooks.php | 17 | ||||
-rw-r--r-- | tests/lib/Accounts/AccountsManagerTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Accounts/HooksTest.php | 11 |
5 files changed, 19 insertions, 30 deletions
diff --git a/lib/base.php b/lib/base.php index a27e8ffc920..f73d4321bfa 100644 --- a/lib/base.php +++ b/lib/base.php @@ -854,7 +854,7 @@ class OC { } private static function registerAccountHooks() { - $hookHandler = new \OC\Accounts\Hooks(\OC::$server->getLogger()); + $hookHandler = new \OC\Accounts\Hooks(\OC::$server->get(\Psr\Log\LoggerInterface::class)); \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); } diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 1f23e7e33a3..d18555d296c 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -35,8 +35,8 @@ use OCP\Accounts\IAccount; use OCP\Accounts\IAccountManager; use OCP\BackgroundJob\IJobList; use OCP\IDBConnection; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use function json_decode; @@ -64,20 +64,13 @@ class AccountManager implements IAccountManager { /** @var IJobList */ private $jobList; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; - /** - * AccountManager constructor. - * - * @param IDBConnection $connection - * @param EventDispatcherInterface $eventDispatcher - * @param IJobList $jobList - */ public function __construct(IDBConnection $connection, EventDispatcherInterface $eventDispatcher, IJobList $jobList, - ILogger $logger) { + LoggerInterface $logger) { $this->connection = $connection; $this->eventDispatcher = $eventDispatcher; $this->jobList = $jobList; diff --git a/lib/private/Accounts/Hooks.php b/lib/private/Accounts/Hooks.php index 2288b884c5c..82f55f5a9d1 100644 --- a/lib/private/Accounts/Hooks.php +++ b/lib/private/Accounts/Hooks.php @@ -24,23 +24,18 @@ namespace OC\Accounts; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; class Hooks { - /** @var AccountManager */ - private $accountManager = null; + /** @var AccountManager|null */ + private $accountManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; - /** - * Hooks constructor. - * - * @param ILogger $logger - */ - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } @@ -85,7 +80,7 @@ class Hooks { * * @return AccountManager */ - protected function getAccountManager() { + protected function getAccountManager(): AccountManager { if ($this->accountManager === null) { $this->accountManager = \OC::$server->query(AccountManager::class); } diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php index 76abeb5b495..de9cc706b6a 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountsManagerTest.php @@ -25,9 +25,9 @@ use OC\Accounts\Account; use OC\Accounts\AccountManager; use OCP\Accounts\IAccountManager; use OCP\BackgroundJob\IJobList; -use OCP\ILogger; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; @@ -52,7 +52,7 @@ class AccountsManagerTest extends TestCase { /** @var string accounts table name */ private $table = 'accounts'; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; protected function setUp(): void { @@ -60,7 +60,7 @@ class AccountsManagerTest extends TestCase { $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); $this->connection = \OC::$server->getDatabaseConnection(); $this->jobList = $this->createMock(IJobList::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); } protected function tearDown(): void { diff --git a/tests/lib/Accounts/HooksTest.php b/tests/lib/Accounts/HooksTest.php index d24afd475e4..39003b2ef23 100644 --- a/tests/lib/Accounts/HooksTest.php +++ b/tests/lib/Accounts/HooksTest.php @@ -23,8 +23,9 @@ namespace Test\Accounts; use OC\Accounts\AccountManager; use OC\Accounts\Hooks; -use OCP\ILogger; use OCP\IUser; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -35,19 +36,19 @@ use Test\TestCase; */ class HooksTest extends TestCase { - /** @var ILogger | \PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; - /** @var AccountManager | \PHPUnit\Framework\MockObject\MockObject */ + /** @var AccountManager|MockObject */ private $accountManager; - /** @var Hooks | \PHPUnit\Framework\MockObject\MockObject */ + /** @var Hooks|MockObject */ private $hooks; protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->accountManager = $this->getMockBuilder(AccountManager::class) ->disableOriginalConstructor()->getMock(); |