diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-09-18 18:59:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-18 18:59:56 +0200 |
commit | 989d708bd896d69575bf662cc2bd0b870d187a7c (patch) | |
tree | a84d2b5c931f43c614ffaf43482f1da6bb4cfcf4 /tests | |
parent | 33928fc671b8ae80c809dcf2f0353c432776979d (diff) | |
parent | b926df47303514b10211e6d1193a3d7310432ca9 (diff) | |
download | nextcloud-server-989d708bd896d69575bf662cc2bd0b870d187a7c.tar.gz nextcloud-server-989d708bd896d69575bf662cc2bd0b870d187a7c.zip |
Merge pull request #48137 from nextcloud/enh/add-rich-object-formatter
feat: Add OCP interface to format richtext into string
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Activity/ManagerTest.php | 17 | ||||
-rw-r--r-- | tests/lib/Notification/ManagerTest.php | 20 | ||||
-rw-r--r-- | tests/lib/Notification/NotificationTest.php | 15 |
3 files changed, 35 insertions, 17 deletions
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php index bb73aea4f6d..61eeee82c43 100644 --- a/tests/lib/Activity/ManagerTest.php +++ b/tests/lib/Activity/ManagerTest.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) ); diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php index 47740ed18b5..2a85316d7c4 100644 --- a/tests/lib/Notification/ManagerTest.php +++ b/tests/lib/Notification/ManagerTest.php @@ -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(); diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php index 48a78bd0fe7..957d74233be 100644 --- a/tests/lib/Notification/NotificationTest.php +++ b/tests/lib/Notification/NotificationTest.php @@ -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()) |