refactor: Migrate away from deprecated ILogger interface to PSR-3

Mostly replace `ILogger` with `LoggerInterface` and some minor cleanup (constructor property promotion).
Some places used the deprecated `logException` this is easy to migrate by simply use the appropriate loglevel on the logger
and place the exception under the `exception` key in the context.
Also the manual checking of the configured log level is not needed, as this is already done by the logger.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen
2024-08-19 13:48:49 +02:00
parent 3e1805b09b
commit beb563e74e
9 changed files with 75 additions and 142 deletions

View File

@@ -27,29 +27,24 @@ use OCA\Deck\Db\Card;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Notification\NotificationHelper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\ILogger;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class ScheduledNoificationsTest extends TestCase {
/** @var ITimeFactory|MockObject */
protected $timeFactory;
/** @var CardMapper|MockObject */
protected $cardMapper;
/** @var NotificationHelper|MockObject */
protected $notificationHelper;
/** @var ILogger|MockObject */
protected $logger;
/** @var ScheduledNotifications */
protected $scheduledNotifications;
protected ITimeFactory&MockObject $timeFactory;
protected CardMapper&MockObject $cardMapper;
protected NotificationHelper&MockObject $notificationHelper;
protected LoggerInterface&MockObject $logger;
protected ScheduledNotifications $scheduledNotifications;
public function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->cardMapper = $this->createMock(CardMapper::class);
$this->notificationHelper = $this->createMock(NotificationHelper::class);
$this->logger = $this->createMock(ILogger::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->scheduledNotifications = new ScheduledNotifications($this->timeFactory, $this->cardMapper, $this->notificationHelper, $this->logger);
}