fix: Adapt notifications and activity tests to new DI dependency

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/48137/head
Côme Chilliet 1 year ago
parent 117c7ee654
commit b926df4730
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 17
      tests/lib/Activity/ManagerTest.php
  2. 20
      tests/lib/Notification/ManagerTest.php
  3. 15
      tests/lib/Notification/NotificationTest.php

@ -14,21 +14,20 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
use OCP\RichObjectStrings\IRichTextFormatter;
use OCP\RichObjectStrings\IValidator;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ManagerTest extends TestCase {
/** @var \OC\Activity\Manager */
private $activityManager;
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
protected $request;
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
protected $session;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
protected $config;
/** @var IValidator|\PHPUnit\Framework\MockObject\MockObject */
protected $validator;
protected IRequest&MockObject $request;
protected IUserSession&MockObject $session;
protected IConfig&MockObject $config;
protected IValidator&MockObject $validator;
protected IRichTextFormatter&MockObject $richTextFormatter;
protected function setUp(): void {
parent::setUp();
@ -37,12 +36,14 @@ class ManagerTest extends TestCase {
$this->session = $this->createMock(IUserSession::class);
$this->config = $this->createMock(IConfig::class);
$this->validator = $this->createMock(IValidator::class);
$this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
$this->activityManager = new \OC\Activity\Manager(
$this->request,
$this->session,
$this->config,
$this->validator,
$this->richTextFormatter,
$this->createMock(IL10N::class)
);

@ -18,6 +18,7 @@ use OCP\ICacheFactory;
use OCP\IUserManager;
use OCP\Notification\IManager;
use OCP\Notification\INotification;
use OCP\RichObjectStrings\IRichTextFormatter;
use OCP\RichObjectStrings\IValidator;
use OCP\Support\Subscription\IRegistry;
use PHPUnit\Framework\MockObject\MockObject;
@ -28,8 +29,8 @@ class ManagerTest extends TestCase {
/** @var IManager */
protected $manager;
/** @var IValidator|MockObject */
protected $validator;
protected IValidator&MockObject $validator;
protected IRichTextFormatter&MockObject $richTextFormatter;
/** @var IUserManager|MockObject */
protected $userManager;
/** @var ICacheFactory|MockObject */
@ -49,6 +50,7 @@ class ManagerTest extends TestCase {
parent::setUp();
$this->validator = $this->createMock(IValidator::class);
$this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->cache = $this->createMock(ICache::class);
$this->subscriptionRegistry = $this->createMock(IRegistry::class);
@ -64,7 +66,15 @@ class ManagerTest extends TestCase {
$this->coordinator->method('getRegistrationContext')
->willReturn($this->registrationContext);
$this->manager = new Manager($this->validator, $this->userManager, $this->cacheFactory, $this->subscriptionRegistry, $this->logger, $this->coordinator);
$this->manager = new Manager(
$this->validator,
$this->userManager,
$this->cacheFactory,
$this->subscriptionRegistry,
$this->logger,
$this->coordinator,
$this->richTextFormatter,
);
}
public function testRegisterApp(): void {
@ -141,6 +151,7 @@ class ManagerTest extends TestCase {
$this->subscriptionRegistry,
$this->logger,
$this->coordinator,
$this->richTextFormatter,
])
->setMethods(['getApps'])
->getMock();
@ -172,6 +183,7 @@ class ManagerTest extends TestCase {
$this->subscriptionRegistry,
$this->logger,
$this->coordinator,
$this->richTextFormatter,
])
->setMethods(['getApps'])
->getMock();
@ -196,6 +208,7 @@ class ManagerTest extends TestCase {
$this->subscriptionRegistry,
$this->logger,
$this->coordinator,
$this->richTextFormatter,
])
->setMethods(['getApps'])
->getMock();
@ -221,6 +234,7 @@ class ManagerTest extends TestCase {
$this->subscriptionRegistry,
$this->logger,
$this->coordinator,
$this->richTextFormatter,
])
->setMethods(['getApps'])
->getMock();

@ -12,19 +12,22 @@ namespace Test\Notification;
use OC\Notification\Notification;
use OCP\Notification\IAction;
use OCP\Notification\INotification;
use OCP\RichObjectStrings\IRichTextFormatter;
use OCP\RichObjectStrings\IValidator;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class NotificationTest extends TestCase {
/** @var INotification */
protected $notification;
/** @var IValidator|\PHPUnit\Framework\MockObject\MockObject */
protected $validator;
protected IValidator&MockObject $validator;
protected IRichTextFormatter&MockObject $richTextFormatter;
protected function setUp(): void {
parent::setUp();
$this->validator = $this->createMock(IValidator::class);
$this->notification = new Notification($this->validator);
$this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
$this->notification = new Notification($this->validator, $this->richTextFormatter);
}
protected function dataValidString($maxLength) {
@ -529,7 +532,7 @@ class NotificationTest extends TestCase {
'getSubject',
'getParsedSubject',
])
->setConstructorArgs([$this->validator])
->setConstructorArgs([$this->validator, $this->richTextFormatter])
->getMock();
$notification->expects($this->once())
@ -562,7 +565,7 @@ class NotificationTest extends TestCase {
'getParsedSubject',
'getSubject',
])
->setConstructorArgs([$this->validator])
->setConstructorArgs([$this->validator, $this->richTextFormatter])
->getMock();
$notification->expects($this->once())
@ -611,7 +614,7 @@ class NotificationTest extends TestCase {
'getObjectType',
'getObjectId',
])
->setConstructorArgs([$this->validator])
->setConstructorArgs([$this->validator, $this->richTextFormatter])
->getMock();
$notification->expects($this->any())

Loading…
Cancel
Save