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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,21 +32,20 @@ use OCA\Deck\Service\PermissionService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use OCP\IRequest;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ExceptionMiddlewareTest extends \Test\TestCase {
|
||||
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
private $request;
|
||||
private $controller;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
private IConfig&MockObject $config;
|
||||
private IRequest&MockObject $request;
|
||||
private Controller&MockObject $controller;
|
||||
private $exceptionMiddleware;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->logger = $this->createMock(ILogger::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
$this->controller = $this->createMock(Controller::class);
|
||||
|
||||
@@ -34,38 +34,29 @@ use OCP\Files\SimpleFS\ISimpleFile;
|
||||
use OCP\Files\SimpleFS\ISimpleFolder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
use OCP\IRequest;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class FileServiceTest extends TestCase {
|
||||
|
||||
/** @var IL10N|MockObject */
|
||||
private $l10n;
|
||||
/** @var IAppData|MockObject */
|
||||
private $appData;
|
||||
/** @var IRequest|MockObject */
|
||||
private $request;
|
||||
/** @var ILogger|MockObject */
|
||||
private $logger;
|
||||
/** @var FileService */
|
||||
private $fileService;
|
||||
/** @var IRootFolder */
|
||||
private $rootFolder;
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
/** @var AttachmentMapper|MockObject */
|
||||
private $attachmentMapper;
|
||||
/** @var IMimeTypeDetector|MockObject */
|
||||
private $mimeTypeDetector;
|
||||
|
||||
private IL10N&MockObject $l10n;
|
||||
private IAppData&MockObject $appData;
|
||||
private IRequest&MockObject $request;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
private IRootFolder&MockObject $rootFolder;
|
||||
private IConfig&MockObject $config;
|
||||
private AttachmentMapper&MockObject $attachmentMapper;
|
||||
private IMimeTypeDetector&MockObject $mimeTypeDetector;
|
||||
private FileService $fileService;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
$this->appData = $this->createMock(IAppData::class);
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->logger = $this->createMock(ILogger::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->rootFolder = $this->createMock(IRootFolder::class);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->attachmentMapper = $this->createMock(AttachmentMapper::class);
|
||||
|
||||
Reference in New Issue
Block a user