diff options
-rw-r--r-- | .github/dependabot.yml | 14 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharesReminderJob.php | 4 | ||||
-rw-r--r-- | core/Command/SetupChecks.php | 27 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | lib/private/Activity/Event.php | 40 | ||||
-rw-r--r-- | lib/private/Activity/Manager.php | 32 | ||||
-rw-r--r-- | lib/private/Files/Cache/SearchBuilder.php | 2 | ||||
-rw-r--r-- | lib/private/Notification/Manager.php | 4 | ||||
-rw-r--r-- | lib/private/Notification/Notification.php | 30 | ||||
-rw-r--r-- | lib/private/RichObjectStrings/RichTextFormatter.php | 36 | ||||
-rw-r--r-- | lib/private/Server.php | 4 | ||||
-rw-r--r-- | lib/public/DB/QueryBuilder/IQueryBuilder.php | 3 | ||||
-rw-r--r-- | lib/public/RichObjectStrings/IRichTextFormatter.php | 25 | ||||
-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 | ||||
-rw-r--r-- | vendor-bin/phpunit/composer.json | 2 | ||||
-rw-r--r-- | vendor-bin/phpunit/composer.lock | 21 |
19 files changed, 160 insertions, 140 deletions
diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 988f05ffb3b..45849759367 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -59,6 +59,20 @@ updates: reviewers: - "nextcloud/server-dependabot" +# phpunit +- package-ecosystem: composer + directory: "/vendor-bin/phpunit" + schedule: + interval: weekly + day: saturday + time: "04:40" + timezone: Europe/Madrid + labels: + - "3. to review" + - "feature: dependencies" + reviewers: + - "nextcloud/server-dependabot" + # Main master npm - package-ecosystem: npm directory: "/" diff --git a/apps/files_sharing/lib/SharesReminderJob.php b/apps/files_sharing/lib/SharesReminderJob.php index 9682f7fc770..6780ee77fe3 100644 --- a/apps/files_sharing/lib/SharesReminderJob.php +++ b/apps/files_sharing/lib/SharesReminderJob.php @@ -89,8 +89,8 @@ class SharesReminderJob extends TimedJob { $qb->expr()->eq('s.share_type', $qb->expr()->literal(IShare::TYPE_EMAIL)) ), $qb->expr()->eq('s.item_type', $qb->expr()->literal('folder')), - $qb->expr()->gte('s.expiration', $qb->createNamedParameter($minDate->format('Y-m-d H:i:s'))), - $qb->expr()->lt('s.expiration', $qb->createNamedParameter($maxDate->format('Y-m-d H:i:s'))), + $qb->expr()->gte('s.expiration', $qb->createNamedParameter($minDate, IQueryBuilder::PARAM_DATE)), + $qb->expr()->lte('s.expiration', $qb->createNamedParameter($maxDate, IQueryBuilder::PARAM_DATE)), $qb->expr()->eq('s.reminder_sent', $qb->createNamedParameter( false, IQueryBuilder::PARAM_BOOL )), diff --git a/core/Command/SetupChecks.php b/core/Command/SetupChecks.php index 1140792f527..fda463b8f6d 100644 --- a/core/Command/SetupChecks.php +++ b/core/Command/SetupChecks.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OC\Core\Command; +use OCP\RichObjectStrings\IRichTextFormatter; use OCP\SetupCheck\ISetupCheckManager; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,6 +17,7 @@ use Symfony\Component\Console\Output\OutputInterface; class SetupChecks extends Base { public function __construct( private ISetupCheckManager $setupCheckManager, + private IRichTextFormatter $richTextFormatter, ) { parent::__construct(); } @@ -29,29 +31,6 @@ class SetupChecks extends Base { ; } - /** - * @TODO move this method to a common service used by notifications, activity and this command - * @throws \InvalidArgumentException if a parameter has no name or no type - */ - private function richToParsed(string $message, array $parameters): string { - $placeholders = []; - $replacements = []; - foreach ($parameters as $placeholder => $parameter) { - $placeholders[] = '{' . $placeholder . '}'; - foreach (['name','type'] as $requiredField) { - if (!isset($parameter[$requiredField]) || !is_string($parameter[$requiredField])) { - throw new \InvalidArgumentException("Invalid rich object, {$requiredField} field is missing"); - } - } - $replacements[] = match($parameter['type']) { - 'user' => '@' . $parameter['name'], - 'file' => $parameter['path'] ?? $parameter['name'], - default => $parameter['name'], - }; - } - return str_replace($placeholders, $replacements, $message); - } - protected function execute(InputInterface $input, OutputInterface $output): int { $results = $this->setupCheckManager->runAll(); switch ($input->getOption('output')) { @@ -79,7 +58,7 @@ class SetupChecks extends Base { $description = $check->getDescription(); $descriptionParameters = $check->getDescriptionParameters(); if ($description !== null && $descriptionParameters !== null) { - $description = $this->richToParsed($description, $descriptionParameters); + $description = $this->richTextFormatter->richToParsed($description, $descriptionParameters); } $output->writeln( "\t\t". diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 78aca5fe883..578395a45b4 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -646,6 +646,7 @@ return array( 'OCP\\Remote\\IInstanceFactory' => $baseDir . '/lib/public/Remote/IInstanceFactory.php', 'OCP\\Remote\\IUser' => $baseDir . '/lib/public/Remote/IUser.php', 'OCP\\RichObjectStrings\\Definitions' => $baseDir . '/lib/public/RichObjectStrings/Definitions.php', + 'OCP\\RichObjectStrings\\IRichTextFormatter' => $baseDir . '/lib/public/RichObjectStrings/IRichTextFormatter.php', 'OCP\\RichObjectStrings\\IValidator' => $baseDir . '/lib/public/RichObjectStrings/IValidator.php', 'OCP\\RichObjectStrings\\InvalidObjectExeption' => $baseDir . '/lib/public/RichObjectStrings/InvalidObjectExeption.php', 'OCP\\Route\\IRoute' => $baseDir . '/lib/public/Route/IRoute.php', @@ -1839,6 +1840,7 @@ return array( 'OC\\Repair\\RepairInvalidShares' => $baseDir . '/lib/private/Repair/RepairInvalidShares.php', 'OC\\Repair\\RepairLogoDimension' => $baseDir . '/lib/private/Repair/RepairLogoDimension.php', 'OC\\Repair\\RepairMimeTypes' => $baseDir . '/lib/private/Repair/RepairMimeTypes.php', + 'OC\\RichObjectStrings\\RichTextFormatter' => $baseDir . '/lib/private/RichObjectStrings/RichTextFormatter.php', 'OC\\RichObjectStrings\\Validator' => $baseDir . '/lib/private/RichObjectStrings/Validator.php', 'OC\\Route\\CachingRouter' => $baseDir . '/lib/private/Route/CachingRouter.php', 'OC\\Route\\Route' => $baseDir . '/lib/private/Route/Route.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 6a17bc4ff31..2e507ec7a5f 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -679,6 +679,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Remote\\IInstanceFactory' => __DIR__ . '/../../..' . '/lib/public/Remote/IInstanceFactory.php', 'OCP\\Remote\\IUser' => __DIR__ . '/../../..' . '/lib/public/Remote/IUser.php', 'OCP\\RichObjectStrings\\Definitions' => __DIR__ . '/../../..' . '/lib/public/RichObjectStrings/Definitions.php', + 'OCP\\RichObjectStrings\\IRichTextFormatter' => __DIR__ . '/../../..' . '/lib/public/RichObjectStrings/IRichTextFormatter.php', 'OCP\\RichObjectStrings\\IValidator' => __DIR__ . '/../../..' . '/lib/public/RichObjectStrings/IValidator.php', 'OCP\\RichObjectStrings\\InvalidObjectExeption' => __DIR__ . '/../../..' . '/lib/public/RichObjectStrings/InvalidObjectExeption.php', 'OCP\\Route\\IRoute' => __DIR__ . '/../../..' . '/lib/public/Route/IRoute.php', @@ -1872,6 +1873,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Repair\\RepairInvalidShares' => __DIR__ . '/../../..' . '/lib/private/Repair/RepairInvalidShares.php', 'OC\\Repair\\RepairLogoDimension' => __DIR__ . '/../../..' . '/lib/private/Repair/RepairLogoDimension.php', 'OC\\Repair\\RepairMimeTypes' => __DIR__ . '/../../..' . '/lib/private/Repair/RepairMimeTypes.php', + 'OC\\RichObjectStrings\\RichTextFormatter' => __DIR__ . '/../../..' . '/lib/private/RichObjectStrings/RichTextFormatter.php', 'OC\\RichObjectStrings\\Validator' => __DIR__ . '/../../..' . '/lib/private/RichObjectStrings/Validator.php', 'OC\\Route\\CachingRouter' => __DIR__ . '/../../..' . '/lib/private/Route/CachingRouter.php', 'OC\\Route\\Route' => __DIR__ . '/../../..' . '/lib/private/Route/Route.php', diff --git a/lib/private/Activity/Event.php b/lib/private/Activity/Event.php index 02cfd758058..810af5c0612 100644 --- a/lib/private/Activity/Event.php +++ b/lib/private/Activity/Event.php @@ -12,6 +12,7 @@ namespace OC\Activity; use OCP\Activity\Exceptions\InvalidValueException; use OCP\Activity\IEvent; use OCP\RichObjectStrings\InvalidObjectExeption; +use OCP\RichObjectStrings\IRichTextFormatter; use OCP\RichObjectStrings\IValidator; class Event implements IEvent { @@ -60,14 +61,11 @@ class Event implements IEvent { /** @var IEvent|null */ protected $child; - /** @var IValidator */ - protected $richValidator; - /** - * @param IValidator $richValidator - */ - public function __construct(IValidator $richValidator) { - $this->richValidator = $richValidator; + public function __construct( + protected IValidator $richValidator, + protected IRichTextFormatter $richTextFormatter, + ) { } /** @@ -217,7 +215,7 @@ class Event implements IEvent { if ($this->subjectParsed === '') { try { - $this->subjectParsed = $this->richToParsed($subject, $parameters); + $this->subjectParsed = $this->richTextFormatter->richToParsed($subject, $parameters); } catch (\InvalidArgumentException $e) { throw new InvalidValueException('richSubjectParameters', $e); } @@ -227,30 +225,6 @@ class Event implements IEvent { } /** - * @throws \InvalidArgumentException if a parameter has no name or no type - */ - private function richToParsed(string $message, array $parameters): string { - $placeholders = []; - $replacements = []; - foreach ($parameters as $placeholder => $parameter) { - $placeholders[] = '{' . $placeholder . '}'; - foreach (['name','type'] as $requiredField) { - if (!isset($parameter[$requiredField]) || !is_string($parameter[$requiredField])) { - throw new \InvalidArgumentException("Invalid rich object, {$requiredField} field is missing"); - } - } - if ($parameter['type'] === 'user') { - $replacements[] = '@' . $parameter['name']; - } elseif ($parameter['type'] === 'file') { - $replacements[] = $parameter['path'] ?? $parameter['name']; - } else { - $replacements[] = $parameter['name']; - } - } - return str_replace($placeholders, $replacements, $message); - } - - /** * @return string * @since 11.0.0 */ @@ -317,7 +291,7 @@ class Event implements IEvent { if ($this->messageParsed === '') { try { - $this->messageParsed = $this->richToParsed($message, $parameters); + $this->messageParsed = $this->richTextFormatter->richToParsed($message, $parameters); } catch (\InvalidArgumentException $e) { throw new InvalidValueException('richMessageParameters', $e); } diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 54d50a47dcb..5c306fe6399 100644 --- a/lib/private/Activity/Manager.php +++ b/lib/private/Activity/Manager.php @@ -21,20 +21,10 @@ use OCP\IL10N; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; +use OCP\RichObjectStrings\IRichTextFormatter; use OCP\RichObjectStrings\IValidator; class Manager implements IManager { - /** @var IRequest */ - protected $request; - - /** @var IUserSession */ - protected $session; - - /** @var IConfig */ - protected $config; - - /** @var IValidator */ - protected $validator; /** @var string */ protected $formattingObjectType; @@ -48,20 +38,14 @@ class Manager implements IManager { /** @var string */ protected $currentUserId; - protected $l10n; - public function __construct( - IRequest $request, - IUserSession $session, - IConfig $config, - IValidator $validator, - IL10N $l10n + protected IRequest $request, + protected IUserSession $session, + protected IConfig $config, + protected IValidator $validator, + protected IRichTextFormatter $richTextFormatter, + protected IL10N $l10n, ) { - $this->request = $request; - $this->session = $session; - $this->config = $config; - $this->validator = $validator; - $this->l10n = $l10n; } /** @var \Closure[] */ @@ -104,7 +88,7 @@ class Manager implements IManager { * @return IEvent */ public function generateEvent(): IEvent { - return new Event($this->validator); + return new Event($this->validator, $this->richTextFormatter); } /** diff --git a/lib/private/Files/Cache/SearchBuilder.php b/lib/private/Files/Cache/SearchBuilder.php index 748844b9e1b..41f942cab03 100644 --- a/lib/private/Files/Cache/SearchBuilder.php +++ b/lib/private/Files/Cache/SearchBuilder.php @@ -64,7 +64,7 @@ class SearchBuilder { 'owner' => 'string', ]; - /** @var array<string, int> */ + /** @var array<string, int|string> */ protected static $paramTypeMap = [ 'string' => IQueryBuilder::PARAM_STR, 'integer' => IQueryBuilder::PARAM_INT, diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index 8edbca0380d..ac287e97048 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -22,6 +22,7 @@ use OCP\Notification\IncompleteParsedNotificationException; use OCP\Notification\INotification; use OCP\Notification\INotifier; use OCP\Notification\UnknownNotificationException; +use OCP\RichObjectStrings\IRichTextFormatter; use OCP\RichObjectStrings\IValidator; use OCP\Support\Subscription\IRegistry; use Psr\Container\ContainerExceptionInterface; @@ -55,6 +56,7 @@ class Manager implements IManager { protected IRegistry $subscription, protected LoggerInterface $logger, private Coordinator $coordinator, + private IRichTextFormatter $richTextFormatter, ) { $this->cache = $cacheFactory->createDistributed('notifications'); @@ -199,7 +201,7 @@ class Manager implements IManager { * @since 8.2.0 */ public function createNotification(): INotification { - return new Notification($this->validator); + return new Notification($this->validator, $this->richTextFormatter); } /** diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php index 19c836c2044..1c624b50d44 100644 --- a/lib/private/Notification/Notification.php +++ b/lib/private/Notification/Notification.php @@ -12,6 +12,7 @@ use OCP\Notification\IAction; use OCP\Notification\INotification; use OCP\Notification\InvalidValueException; use OCP\RichObjectStrings\InvalidObjectExeption; +use OCP\RichObjectStrings\IRichTextFormatter; use OCP\RichObjectStrings\IValidator; class Notification implements INotification { @@ -39,6 +40,7 @@ class Notification implements INotification { public function __construct( protected IValidator $richValidator, + protected IRichTextFormatter $richTextFormatter, ) { $this->dateTime = new \DateTime(); $this->dateTime->setTimestamp(0); @@ -187,7 +189,7 @@ class Notification implements INotification { if ($this->subjectParsed === '') { try { - $this->subjectParsed = $this->richToParsed($subject, $parameters); + $this->subjectParsed = $this->richTextFormatter->richToParsed($subject, $parameters); } catch (\InvalidArgumentException $e) { throw new InvalidValueException('richSubjectParameters', $e); } @@ -197,30 +199,6 @@ class Notification implements INotification { } /** - * @throws \InvalidArgumentException if a parameter has no name or no type - */ - private function richToParsed(string $message, array $parameters): string { - $placeholders = []; - $replacements = []; - foreach ($parameters as $placeholder => $parameter) { - $placeholders[] = '{' . $placeholder . '}'; - foreach (['name','type'] as $requiredField) { - if (!isset($parameter[$requiredField]) || !is_string($parameter[$requiredField])) { - throw new \InvalidArgumentException("Invalid rich object, {$requiredField} field is missing"); - } - } - if ($parameter['type'] === 'user') { - $replacements[] = '@' . $parameter['name']; - } elseif ($parameter['type'] === 'file') { - $replacements[] = $parameter['path'] ?? $parameter['name']; - } else { - $replacements[] = $parameter['name']; - } - } - return str_replace($placeholders, $replacements, $message); - } - - /** * {@inheritDoc} */ public function getRichSubject(): string { @@ -293,7 +271,7 @@ class Notification implements INotification { if ($this->messageParsed === '') { try { - $this->messageParsed = $this->richToParsed($message, $parameters); + $this->messageParsed = $this->richTextFormatter->richToParsed($message, $parameters); } catch (\InvalidArgumentException $e) { throw new InvalidValueException('richMessageParameters', $e); } diff --git a/lib/private/RichObjectStrings/RichTextFormatter.php b/lib/private/RichObjectStrings/RichTextFormatter.php new file mode 100644 index 00000000000..9c9ddf94fa9 --- /dev/null +++ b/lib/private/RichObjectStrings/RichTextFormatter.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\RichObjectStrings; + +use OCP\RichObjectStrings\IRichTextFormatter; + +class RichTextFormatter implements IRichTextFormatter { + /** + * @throws \InvalidArgumentException if a parameter has no name or no type + */ + public function richToParsed(string $message, array $parameters): string { + $placeholders = []; + $replacements = []; + foreach ($parameters as $placeholder => $parameter) { + $placeholders[] = '{' . $placeholder . '}'; + foreach (['name','type'] as $requiredField) { + if (!isset($parameter[$requiredField]) || !is_string($parameter[$requiredField])) { + throw new \InvalidArgumentException("Invalid rich object, {$requiredField} field is missing"); + } + } + $replacements[] = match($parameter['type']) { + 'user' => '@' . $parameter['name'], + 'file' => $parameter['path'] ?? $parameter['name'], + default => $parameter['name'], + }; + } + return str_replace($placeholders, $replacements, $message); + } +} diff --git a/lib/private/Server.php b/lib/private/Server.php index 7ecafdcd66c..f48cc0d0a48 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -204,6 +204,7 @@ use OCP\Profile\IProfileManager; use OCP\Profiler\IProfiler; use OCP\Remote\Api\IApiFactory; use OCP\Remote\IInstanceFactory; +use OCP\RichObjectStrings\IRichTextFormatter; use OCP\RichObjectStrings\IValidator; use OCP\Route\IRouter; use OCP\Security\Bruteforce\IThrottler; @@ -648,6 +649,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(IUserSession::class), $c->get(\OCP\IConfig::class), $c->get(IValidator::class), + $c->get(IRichTextFormatter::class), $l10n ); }); @@ -1285,6 +1287,8 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class); + $this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class); + $this->connectDispatcher(); } diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index a965e0b5390..72b2ccbecff 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -10,6 +10,7 @@ namespace OCP\DB\QueryBuilder; use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; use Doctrine\DBAL\ParameterType; +use Doctrine\DBAL\Types\Types; use OCP\DB\Exception; use OCP\DB\IResult; use OCP\IDBConnection; @@ -28,7 +29,7 @@ interface IQueryBuilder { /** * @since 9.0.0 */ - public const PARAM_BOOL = ParameterType::BOOLEAN; + public const PARAM_BOOL = Types::BOOLEAN; /** * @since 9.0.0 */ diff --git a/lib/public/RichObjectStrings/IRichTextFormatter.php b/lib/public/RichObjectStrings/IRichTextFormatter.php new file mode 100644 index 00000000000..1d72f480b07 --- /dev/null +++ b/lib/public/RichObjectStrings/IRichTextFormatter.php @@ -0,0 +1,25 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\RichObjectStrings; + +/** + * Parse rich text and format it with the richobjects + * + * @since 31.0.0 + */ +interface IRichTextFormatter { + /** + * @since 31.0.0 + * @param string $message + * @param array<string,array<string,string>> $parameters + * @throws \InvalidArgumentException if a parameter has no name or no type + */ + public function richToParsed(string $message, array $parameters): string; +} 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()) diff --git a/vendor-bin/phpunit/composer.json b/vendor-bin/phpunit/composer.json index 6a55385959d..9f0239b8d08 100644 --- a/vendor-bin/phpunit/composer.json +++ b/vendor-bin/phpunit/composer.json @@ -6,6 +6,6 @@ } }, "require": { - "phpunit/phpunit": "9.6" + "phpunit/phpunit": "^9.6" } } diff --git a/vendor-bin/phpunit/composer.lock b/vendor-bin/phpunit/composer.lock index 864ab93f654..051e9b97b1f 100644 --- a/vendor-bin/phpunit/composer.lock +++ b/vendor-bin/phpunit/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "584c6c41b403750738431da544faf245", + "content-hash": "270e67431f5fc8b58ecfeea7ce934f21", "packages": [ { "name": "doctrine/instantiator", @@ -632,16 +632,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.0", + "version": "9.6.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "70fc8be1d0b9fad56a199a4df5f9cfabfc246f84" + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/70fc8be1d0b9fad56a199a4df5f9cfabfc246f84", - "reference": "70fc8be1d0b9fad56a199a4df5f9cfabfc246f84", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", "shasum": "" }, "require": { @@ -656,7 +656,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -674,8 +674,8 @@ "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -714,7 +714,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.0" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" }, "funding": [ { @@ -730,7 +731,7 @@ "type": "tidelift" } ], - "time": "2023-02-03T07:32:24+00:00" + "time": "2024-04-05T04:35:58+00:00" }, { "name": "sebastian/cli-parser", |