summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2023-08-07 13:26:39 +0200
committerGitHub <noreply@github.com>2023-08-07 13:26:39 +0200
commitf099aa2714f163947c9ae678b67ea022c69c3d62 (patch)
tree7be9449f7682896e67cb09f493ec51af58bdb147 /tests
parentf62711d2ae78d807bbd3675ff26aa8852a18b7c1 (diff)
parent787caefc9a58cf9cd105454b6b5a2d8046509878 (diff)
downloadnextcloud-server-f099aa2714f163947c9ae678b67ea022c69c3d62.tar.gz
nextcloud-server-f099aa2714f163947c9ae678b67ea022c69c3d62.zip
Merge branch 'master' into fix/llm-migration-not-executed
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php2
-rw-r--r--tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js9
-rw-r--r--tests/data/integritycheck/mimetypeListModified/core/signature.json4
-rw-r--r--tests/karma.config.js13
-rw-r--r--tests/lib/Accounts/AccountManagerTest.php21
-rw-r--r--tests/lib/EventDispatcher/SymfonyAdapterTest.php191
-rw-r--r--tests/lib/Share20/LegacyHooksTest.php39
-rw-r--r--tests/lib/Share20/ManagerTest.php165
-rw-r--r--tests/lib/TextProcessing/TextProcessingTest.php7
9 files changed, 131 insertions, 320 deletions
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index ec1f89e1462..b73b8389c49 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -196,7 +196,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function tabHeaderInDetailsViewNamed($tabHeaderName) {
- return Locator::forThe()->xpath("//li[normalize-space() = '$tabHeaderName']")->
+ return Locator::forThe()->xpath("//span[contains(@class, 'app-sidebar-tabs__tab') and normalize-space() = '$tabHeaderName']")->
descendantOf(self::tabHeadersInDetailsView())->
describedAs("Tab header named $tabHeaderName in details view in Files app");
}
diff --git a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
index 7fa68a44dcb..a8e98e786f5 100644
--- a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
+++ b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
@@ -10,8 +10,8 @@ OC.MimeTypeList={
aliases: {
"application/coreldraw": "image",
"application/epub+zip": "text",
- "application/font-sfnt": "image",
- "application/font-woff": "image",
+ "application/font-sfnt": "font",
+ "application/font-woff": "font",
"application/gpx+xml": "location",
"application/gzip": "package/x-generic",
"application/illustrator": "image",
@@ -35,7 +35,7 @@ OC.MimeTypeList={
"application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet",
"application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet",
"application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet",
- "application/vnd.ms-fontobject": "image",
+ "application/vnd.ms-fontobject": "font",
"application/vnd.ms-powerpoint": "x-office/presentation",
"application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation",
@@ -79,7 +79,7 @@ OC.MimeTypeList={
"application/x-dcraw": "image",
"application/x-deb": "package/x-generic",
"application/x-fictionbook+xml": "text",
- "application/x-font": "image",
+ "application/x-font": "font",
"application/x-gimp": "image",
"application/x-gzip": "application/gzip",
"application/x-iwork-keynote-sffkey": "x-office/presentation",
@@ -129,6 +129,7 @@ OC.MimeTypeList={
"folder-public",
"folder-shared",
"folder-starred",
+ "font",
"image",
"link",
"location",
diff --git a/tests/data/integritycheck/mimetypeListModified/core/signature.json b/tests/data/integritycheck/mimetypeListModified/core/signature.json
index aff5fb38e41..43f489f6d3f 100644
--- a/tests/data/integritycheck/mimetypeListModified/core/signature.json
+++ b/tests/data/integritycheck/mimetypeListModified/core/signature.json
@@ -1,7 +1,7 @@
{
"hashes": {
- "core\/js\/mimetypelist.js": "e47768d024b1b8cc4a24c91892e9b4a4489c713f9aa8b251e6a300a954d3105d56ae2214519c62ef0d621102cac91eb009c863f7b9368e9f463a4f102a1ad91b"
+ "core\/js\/mimetypelist.js": "2a6ab9af5353d464c0dd3bd651cfc13ba35009463949bc45bd8f7073828fa34fbdac7a81ba2b188e7e0c97fc63c2167825b069f61341e507ca33213b1e6e4593"
},
- "signature": "r24gCYJNRAR7PoX9jEWOkx7ErNucehmdbskGQJIhLPdUbFyBoQw4wgFPlrf8j4GDkchEbpcq0Kf1Bp\/JRuV47TVj+rrmqgX\/LqQKgbENxws8rZy9EXoG9slb7LnMhpueRQdnT94KvU7ntbwSXE4BM0tbE51\/rHtAvtnUbkDiZuv\/d6dRjRVbJ5\/Br+DIPveMJSgRBD+gNwktXTWQ6wEHFBynuqASZFNFypZ4OJyM4KXhlYWpl5Bx5pqAXpWroyOVIu1GB83EAf5vwjc9fHH8Envu13WGDZB5MIQc+h22r\/4j\/scugfL3RbDZie3JSq3ADV+TmsBra9gYsLdE0zde8AQRlb1cugldzKNpjcguyjZ8PP\/8mCg8cBSesRF9Qo2RN\/MWiaB+JPjusY76uNfXhfG7pQ06SCkU5S1\/AxdIGi5VfGGi08lVJWEIZzmOuXzvbx1hacAxSOmDIq2j3j8JirMobGURzn+zDjl94qZ9Y2AG5SIgdGBfKmBQRmbiPGO1sGfjFFVPotlFvFxZlKl8cMkLK2gmXIzyxe8OkfL66LSinfxiDQDuAeFLX7IMtkIDreQHhWFatFj1G\/3TjLwxaRzm+dk9L70f0DSkhg603zdQQvR7dQ9VOnGwlFlnMpDYRMc\/pLWEYn7vp2A1wQFrb5CEU+C84ll8oKeNrhfEyBM=",
+ "signature": "A5JmjvGiWC9iDaDL0\/wzIBx1ovV6xW5pL134ZtzcFh6dCRoYVZFZvInb98zz4Js3Y4R+uAv4XYKFgclG9BXjoa+q7SmN4qV95o870OsX3MEAaPRHEJv7V6P19h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\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
} \ No newline at end of file
diff --git a/tests/karma.config.js b/tests/karma.config.js
index 1b36dbfed5c..064ac196b3e 100644
--- a/tests/karma.config.js
+++ b/tests/karma.config.js
@@ -72,19 +72,6 @@ module.exports = function(config) {
],
testFiles: ['apps/files_sharing/tests/js/*.js']
},
- {
- name: 'files_external',
- srcFiles: [
- // only test these files, others are not ready and mess
- // up with the global namespace/classes/state
- 'apps/files_external/js/app.js',
- 'apps/files_external/js/templates.js',
- 'apps/files_external/js/mountsfilelist.js',
- 'apps/files_external/js/settings.js',
- 'apps/files_external/js/statusmanager.js'
- ],
- testFiles: ['apps/files_external/tests/js/*.js']
- },
'systemtags',
'files_trashbin',
];
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php
index 3a3405f18a0..d12dfbfacea 100644
--- a/tests/lib/Accounts/AccountManagerTest.php
+++ b/tests/lib/Accounts/AccountManagerTest.php
@@ -28,8 +28,10 @@ use OC\Accounts\Account;
use OC\Accounts\AccountManager;
use OCA\Settings\BackgroundJobs\VerifyUserData;
use OCP\Accounts\IAccountManager;
+use OCP\Accounts\UserUpdatedEvent;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IURLGenerator;
@@ -40,8 +42,6 @@ use OCP\Security\ICrypto;
use OCP\Security\VerificationToken\IVerificationToken;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
use Test\TestCase;
/**
@@ -70,7 +70,7 @@ class AccountManagerTest extends TestCase {
/** @var IConfig|MockObject */
private $config;
- /** @var EventDispatcherInterface|MockObject */
+ /** @var IEventDispatcher|MockObject */
private $eventDispatcher;
/** @var IJobList|MockObject */
@@ -86,7 +86,7 @@ class AccountManagerTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->connection = \OC::$server->get(IDBConnection::class);
$this->config = $this->createMock(IConfig::class);
$this->jobList = $this->createMock(IJobList::class);
@@ -502,15 +502,14 @@ class AccountManagerTest extends TestCase {
if (!$insertNew && !$updateExisting) {
$accountManager->expects($this->never())->method('updateExistingUser');
$accountManager->expects($this->never())->method('insertNewUser');
- $this->eventDispatcher->expects($this->never())->method('dispatch');
+ $this->eventDispatcher->expects($this->never())->method('dispatchTyped');
} else {
- $this->eventDispatcher->expects($this->once())->method('dispatch')
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')
->willReturnCallback(
- function ($eventName, $event) use ($user, $newData) {
- $this->assertSame('OC\AccountManager::userUpdated', $eventName);
- $this->assertInstanceOf(GenericEvent::class, $event);
- $this->assertSame($user, $event->getSubject());
- $this->assertSame($newData, $event->getArguments());
+ function ($event) use ($user, $newData) {
+ $this->assertInstanceOf(UserUpdatedEvent::class, $event);
+ $this->assertSame($user, $event->getUser());
+ $this->assertSame($newData, $event->getData());
}
);
}
diff --git a/tests/lib/EventDispatcher/SymfonyAdapterTest.php b/tests/lib/EventDispatcher/SymfonyAdapterTest.php
deleted file mode 100644
index 623706f9da7..00000000000
--- a/tests/lib/EventDispatcher/SymfonyAdapterTest.php
+++ /dev/null
@@ -1,191 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/*
- * @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-namespace lib\EventDispatcher;
-
-use OC\EventDispatcher\EventDispatcher;
-use OC\EventDispatcher\GenericEventWrapper;
-use OC\EventDispatcher\SymfonyAdapter;
-use OCP\EventDispatcher\Event;
-use OCP\EventDispatcher\GenericEvent;
-use PHPUnit\Framework\MockObject\MockObject;
-use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
-use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent as SymfonyGenericEvent;
-use Test\TestCase;
-
-class SymfonyAdapterTest extends TestCase {
- /** @var EventDispatcher|MockObject */
- private $eventDispatcher;
-
- /** @var LoggerInterface|MockObject */
- private $logger;
-
- /** @var EventDispatcherInterface */
- private $adapter;
-
- protected function setUp(): void {
- parent::setUp();
-
- $this->eventDispatcher = $this->createMock(EventDispatcher::class);
- $this->logger = $this->createMock(LoggerInterface::class);
-
- $this->adapter = new SymfonyAdapter(
- $this->eventDispatcher,
- $this->logger
- );
- }
-
- public function testDispatchTypedEvent(): void {
- $event = new Event();
- $eventName = 'symfony';
- $this->eventDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- $eventName,
- $event
- )
- ->willReturnArgument(0);
-
- $this->adapter->dispatch($eventName, $event);
- }
-
- public function testDispatchSymfonyGenericEvent(): void {
- $eventName = 'symfony';
- $event = new SymfonyGenericEvent();
- $wrapped = new GenericEventWrapper(
- $this->logger,
- $eventName,
- $event
- );
- $symfonyDispatcher = $this->createMock(SymfonyDispatcher::class);
- $this->eventDispatcher->expects(self::once())
- ->method('getSymfonyDispatcher')
- ->willReturn($symfonyDispatcher);
- $symfonyDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- self::equalTo($wrapped),
- $eventName
- )
- ->willReturnArgument(0);
-
- $result = $this->adapter->dispatch($eventName, $event);
-
- self::assertEquals($result, $wrapped);
- }
-
- public function testDispatchOldSymfonyEventWithFlippedArgumentOrder(): void {
- $event = new SymfonyEvent();
- $eventName = 'symfony';
- $symfonyDispatcher = $this->createMock(SymfonyDispatcher::class);
- $this->eventDispatcher->expects(self::once())
- ->method('getSymfonyDispatcher')
- ->willReturn($symfonyDispatcher);
- $symfonyDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- $event,
- $eventName
- )
- ->willReturnArgument(0);
-
- $result = $this->adapter->dispatch($event, $eventName);
-
- self::assertSame($result, $event);
- }
-
- public function testDispatchOldSymfonyEvent(): void {
- $event = new SymfonyEvent();
- $eventName = 'symfony';
- $symfonyDispatcher = $this->createMock(SymfonyDispatcher::class);
- $this->eventDispatcher->expects(self::once())
- ->method('getSymfonyDispatcher')
- ->willReturn($symfonyDispatcher);
- $symfonyDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- $event,
- $eventName
- )
- ->willReturnArgument(0);
-
- $result = $this->adapter->dispatch($eventName, $event);
-
- self::assertSame($result, $event);
- }
-
- public function testDispatchCustomGenericEventWithFlippedArgumentOrder(): void {
- $event = new GenericEvent();
- $eventName = 'symfony';
- $this->eventDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- $eventName,
- $event
- )
- ->willReturnArgument(0);
-
- $result = $this->adapter->dispatch($event, $eventName);
-
- self::assertSame($result, $event);
- }
-
- public function testDispatchCustomGenericEvent(): void {
- $event = new GenericEvent();
- $eventName = 'symfony';
- $this->eventDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- $eventName,
- $event
- );
-
- $result = $this->adapter->dispatch($eventName, $event);
-
- self::assertSame($result, $event);
- }
-
- public function testDispatchEventWithoutPayload(): void {
- $eventName = 'symfony';
- $symfonyDispatcher = $this->createMock(SymfonyDispatcher::class);
- $this->eventDispatcher->expects(self::once())
- ->method('getSymfonyDispatcher')
- ->willReturn($symfonyDispatcher);
- $symfonyDispatcher->expects(self::once())
- ->method('dispatch')
- ->with(
- $this->anything(),
- $eventName
- )
- ->willReturnArgument(0);
-
- $result = $this->adapter->dispatch($eventName);
-
- self::assertNotNull($result);
- }
-}
diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php
index 54d8e0be725..728f320ea9e 100644
--- a/tests/lib/Share20/LegacyHooksTest.php
+++ b/tests/lib/Share20/LegacyHooksTest.php
@@ -23,7 +23,6 @@
namespace Test\Share20;
-use OC\EventDispatcher\SymfonyAdapter;
use OC\Share20\LegacyHooks;
use OC\Share20\Manager;
use OCP\Constants;
@@ -31,9 +30,13 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\File;
use OCP\IServerContainer;
+use OCP\Share\Events\BeforeShareCreatedEvent;
+use OCP\Share\Events\BeforeShareDeletedEvent;
+use OCP\Share\Events\ShareCreatedEvent;
+use OCP\Share\Events\ShareDeletedEvent;
+use OCP\Share\Events\ShareDeletedFromSelfEvent;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
use Test\TestCase;
class LegacyHooksTest extends TestCase {
@@ -51,9 +54,8 @@ class LegacyHooksTest extends TestCase {
$symfonyDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
$logger = $this->createMock(LoggerInterface::class);
- $eventDispatcher = new \OC\EventDispatcher\EventDispatcher($symfonyDispatcher, \OC::$server->get(IServerContainer::class), $logger);
- $this->eventDispatcher = new SymfonyAdapter($eventDispatcher, $logger);
- $this->hooks = new LegacyHooks($eventDispatcher);
+ $this->eventDispatcher = new \OC\EventDispatcher\EventDispatcher($symfonyDispatcher, \OC::$server->get(IServerContainer::class), $logger);
+ $this->hooks = new LegacyHooks($this->eventDispatcher);
$this->manager = \OC::$server->getShareManager();
}
@@ -94,8 +96,8 @@ class LegacyHooksTest extends TestCase {
->method('pre')
->with($hookListnerExpectsPre);
- $event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::preUnshare', $event);
+ $event = new BeforeShareDeletedEvent($share);
+ $this->eventDispatcher->dispatchTyped($event);
}
public function testPostUnshare() {
@@ -148,9 +150,8 @@ class LegacyHooksTest extends TestCase {
->method('post')
->with($hookListnerExpectsPost);
- $event = new GenericEvent($share);
- $event->setArgument('deletedShares', [$share]);
- $this->eventDispatcher->dispatch('OCP\Share::postUnshare', $event);
+ $event = new ShareDeletedEvent($share);
+ $this->eventDispatcher->dispatchTyped($event);
}
public function testPostUnshareFromSelf() {
@@ -205,8 +206,8 @@ class LegacyHooksTest extends TestCase {
->method('postFromSelf')
->with($hookListnerExpectsPostFromSelf);
- $event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event);
+ $event = new ShareDeletedFromSelfEvent($share);
+ $this->eventDispatcher->dispatchTyped($event);
}
public function testPreShare() {
@@ -253,8 +254,8 @@ class LegacyHooksTest extends TestCase {
->method('preShare')
->with($expected);
- $event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::preShare', $event);
+ $event = new BeforeShareCreatedEvent($share);
+ $this->eventDispatcher->dispatchTyped($event);
}
public function testPreShareError() {
@@ -305,11 +306,11 @@ class LegacyHooksTest extends TestCase {
$data['error'] = 'I error';
});
- $event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::preShare', $event);
+ $event = new BeforeShareCreatedEvent($share);
+ $this->eventDispatcher->dispatchTyped($event);
$this->assertTrue($event->isPropagationStopped());
- $this->assertSame('I error', $event->getArgument('error'));
+ $this->assertSame('I error', $event->getError());
}
public function testPostShare() {
@@ -355,7 +356,7 @@ class LegacyHooksTest extends TestCase {
->method('postShare')
->with($expected);
- $event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::postShare', $event);
+ $event = new ShareCreatedEvent($share);
+ $this->eventDispatcher->dispatchTyped($event);
}
}
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index a23aa6023af..e8704600e2a 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -51,6 +51,11 @@ use OCP\Mail\IMailer;
use OCP\Security\Events\ValidatePasswordPolicyEvent;
use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
+use OCP\Share\Events\BeforeShareCreatedEvent;
+use OCP\Share\Events\BeforeShareDeletedEvent;
+use OCP\Share\Events\ShareCreatedEvent;
+use OCP\Share\Events\ShareDeletedEvent;
+use OCP\Share\Events\ShareDeletedFromSelfEvent;
use OCP\Share\Exceptions\AlreadySharedException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
@@ -60,8 +65,6 @@ use OCP\Share\IShareProvider;
use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class ManagerTest
@@ -96,8 +99,6 @@ class ManagerTest extends \Test\TestCase {
protected $userManager;
/** @var IRootFolder | MockObject */
protected $rootFolder;
- /** @var EventDispatcherInterface | MockObject */
- protected $eventDispatcher;
/** @var IEventDispatcher|MockObject */
protected $dispatcher;
/** @var IMailer|MockObject */
@@ -120,7 +121,6 @@ class ManagerTest extends \Test\TestCase {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
- $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->mailer = $this->createMock(IMailer::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->defaults = $this->createMock(\OC_Defaults::class);
@@ -153,7 +153,6 @@ class ManagerTest extends \Test\TestCase {
$this->factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -184,7 +183,6 @@ class ManagerTest extends \Test\TestCase {
$this->factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -247,17 +245,16 @@ class ManagerTest extends \Test\TestCase {
->method('delete')
->with($share);
- $this->eventDispatcher->expects($this->exactly(2))
- ->method('dispatch')
+ $this->dispatcher->expects($this->exactly(2))
+ ->method('dispatchTyped')
->withConsecutive(
- ['OCP\Share::preUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share;
+ [
+ $this->callBack(function (BeforeShareDeletedEvent $e) use ($share) {
+ return $e->getShare() === $share;
})],
- ['OCP\Share::postUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share &&
- $e->getArgument('deletedShares') === [$share];
+ [
+ $this->callBack(function (ShareDeletedEvent $e) use ($share) {
+ return $e->getShare() === $share;
})]
);
@@ -291,17 +288,16 @@ class ManagerTest extends \Test\TestCase {
->method('delete')
->with($share);
- $this->eventDispatcher->expects($this->exactly(2))
- ->method('dispatch')
+ $this->dispatcher->expects($this->exactly(2))
+ ->method('dispatchTyped')
->withConsecutive(
- ['OCP\Share::preUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share;
+ [
+ $this->callBack(function (BeforeShareDeletedEvent $e) use ($share) {
+ return $e->getShare() === $share;
})],
- ['OCP\Share::postUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share &&
- $e->getArgument('deletedShares') === [$share];
+ [
+ $this->callBack(function (ShareDeletedEvent $e) use ($share) {
+ return $e->getShare() === $share;
})]
);
@@ -356,18 +352,39 @@ class ManagerTest extends \Test\TestCase {
->method('delete')
->withConsecutive([$share3], [$share2], [$share1]);
- $this->eventDispatcher->expects($this->exactly(2))
- ->method('dispatch')
+ $this->dispatcher->expects($this->exactly(6))
+ ->method('dispatchTyped')
->withConsecutive(
- ['OCP\Share::preUnshare',
- $this->callBack(function (GenericEvent $e) use ($share1) {
- return $e->getSubject() === $share1;
- })],
- ['OCP\Share::postUnshare',
- $this->callBack(function (GenericEvent $e) use ($share1, $share2, $share3) {
- return $e->getSubject() === $share1 &&
- $e->getArgument('deletedShares') === [$share3, $share2, $share1];
- })]
+ [
+ $this->callBack(function (BeforeShareDeletedEvent $e) use ($share1) {
+ return $e->getShare()->getId() === $share1->getId();
+ })
+ ],
+ [
+ $this->callBack(function (BeforeShareDeletedEvent $e) use ($share2) {
+ return $e->getShare()->getId() === $share2->getId();
+ })
+ ],
+ [
+ $this->callBack(function (BeforeShareDeletedEvent $e) use ($share3) {
+ return $e->getShare()->getId() === $share3->getId();
+ })
+ ],
+ [
+ $this->callBack(function (ShareDeletedEvent $e) use ($share3) {
+ return $e->getShare()->getId() === $share3->getId();
+ })
+ ],
+ [
+ $this->callBack(function (ShareDeletedEvent $e) use ($share2) {
+ return $e->getShare()->getId() === $share2->getId();
+ })
+ ],
+ [
+ $this->callBack(function (ShareDeletedEvent $e) use ($share1) {
+ return $e->getShare()->getId() === $share1->getId();
+ })
+ ],
);
$manager->deleteShare($share1);
@@ -395,12 +412,11 @@ class ManagerTest extends \Test\TestCase {
->method('deleteFromSelf')
->with($share, $recipientId);
- $this->eventDispatcher->expects($this->once())
- ->method('dispatch')
+ $this->dispatcher->expects($this->once())
+ ->method('dispatchTyped')
->with(
- 'OCP\Share::postUnshareFromSelf',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share;
+ $this->callBack(function (ShareDeletedFromSelfEvent $e) use ($share) {
+ return $e->getShare() === $share;
})
);
@@ -2317,14 +2333,13 @@ class ManagerTest extends \Test\TestCase {
return $share->setId(42);
});
- $this->eventDispatcher->expects($this->exactly(2))
- ->method('dispatch')
+ $this->dispatcher->expects($this->exactly(2))
+ ->method('dispatchTyped')
->withConsecutive(
// Pre share
- [$this->equalTo('OCP\Share::preShare'),
- $this->callback(function (GenericEvent $e) use ($path, $date) {
- /** @var IShare $share */
- $share = $e->getSubject();
+ [
+ $this->callback(function (BeforeShareCreatedEvent $e) use ($path, $date) {
+ $share = $e->getShare();
return $share->getShareType() === IShare::TYPE_LINK &&
$share->getNode() === $path &&
@@ -2333,12 +2348,12 @@ class ManagerTest extends \Test\TestCase {
$share->getExpirationDate() === $date &&
$share->getPassword() === 'hashed' &&
$share->getToken() === 'token';
- })],
+ })
+ ],
// Post share
- [$this->equalTo('OCP\Share::postShare'),
- $this->callback(function (GenericEvent $e) use ($path, $date) {
- /** @var IShare $share */
- $share = $e->getSubject();
+ [
+ $this->callback(function (ShareCreatedEvent $e) use ($path, $date) {
+ $share = $e->getShare();
return $share->getShareType() === IShare::TYPE_LINK &&
$share->getNode() === $path &&
@@ -2349,7 +2364,8 @@ class ManagerTest extends \Test\TestCase {
$share->getToken() === 'token' &&
$share->getId() === '42' &&
$share->getTarget() === '/target';
- })]
+ })
+ ]
);
/** @var IShare $share */
@@ -2424,13 +2440,12 @@ class ManagerTest extends \Test\TestCase {
return $share->setId(42);
});
- $this->eventDispatcher->expects($this->exactly(2))
- ->method('dispatch')
+ $this->dispatcher->expects($this->exactly(2))
+ ->method('dispatchTyped')
->withConsecutive(
- [$this->equalTo('OCP\Share::preShare'),
- $this->callback(function (GenericEvent $e) use ($path) {
- /** @var IShare $share */
- $share = $e->getSubject();
+ [
+ $this->callback(function (BeforeShareCreatedEvent $e) use ($path) {
+ $share = $e->getShare();
return $share->getShareType() === IShare::TYPE_EMAIL &&
$share->getNode() === $path &&
@@ -2439,11 +2454,11 @@ class ManagerTest extends \Test\TestCase {
$share->getExpirationDate() === null &&
$share->getPassword() === null &&
$share->getToken() === 'token';
- })],
- [$this->equalTo('OCP\Share::postShare'),
- $this->callback(function (GenericEvent $e) use ($path) {
- /** @var IShare $share */
- $share = $e->getSubject();
+ })
+ ],
+ [
+ $this->callback(function (ShareCreatedEvent $e) use ($path) {
+ $share = $e->getShare();
return $share->getShareType() === IShare::TYPE_EMAIL &&
$share->getNode() === $path &&
@@ -2454,7 +2469,8 @@ class ManagerTest extends \Test\TestCase {
$share->getToken() === 'token' &&
$share->getId() === '42' &&
$share->getTarget() === '/target';
- })],
+ })
+ ],
);
/** @var IShare $share */
@@ -2521,13 +2537,12 @@ class ManagerTest extends \Test\TestCase {
->with('/target');
// Pre share
- $this->eventDispatcher->expects($this->once())
- ->method('dispatch')
+ $this->dispatcher->expects($this->once())
+ ->method('dispatchTyped')
->with(
- $this->equalTo('OCP\Share::preShare'),
- $this->isInstanceOf(GenericEvent::class)
- )->willReturnCallback(function ($name, GenericEvent $e) {
- $e->setArgument('error', 'I won\'t let you share!');
+ $this->isInstanceOf(BeforeShareCreatedEvent::class)
+ )->willReturnCallback(function (BeforeShareCreatedEvent $e) {
+ $e->setError('I won\'t let you share!');
$e->stopPropagation();
}
);
@@ -2733,7 +2748,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -2779,7 +2793,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -2832,7 +2845,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -4174,7 +4186,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -4209,7 +4220,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -4275,7 +4285,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -4393,7 +4402,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
@@ -4520,7 +4528,6 @@ class ManagerTest extends \Test\TestCase {
$factory,
$this->userManager,
$this->rootFolder,
- $this->eventDispatcher,
$this->mailer,
$this->urlGenerator,
$this->defaults,
diff --git a/tests/lib/TextProcessing/TextProcessingTest.php b/tests/lib/TextProcessing/TextProcessingTest.php
index 1649072ae8c..3bda73e995b 100644
--- a/tests/lib/TextProcessing/TextProcessingTest.php
+++ b/tests/lib/TextProcessing/TextProcessingTest.php
@@ -21,6 +21,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Common\Exception\NotFoundException;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IConfig;
use OCP\IServerContainer;
use OCP\TextProcessing\Events\TaskFailedEvent;
use OCP\TextProcessing\Events\TaskSuccessfulEvent;
@@ -157,12 +158,18 @@ class TextProcessingTest extends \Test\TestCase {
$this->jobList->expects($this->any())->method('add')->willReturnCallback(function () {
});
+ $config = $this->createMock(IConfig::class);
+ $config->method('getAppValue')
+ ->with('core', 'ai.textprocessing_provider_preferences', '')
+ ->willReturn('');
+
$this->manager = new Manager(
$this->serverContainer,
$this->coordinator,
\OC::$server->get(LoggerInterface::class),
$this->jobList,
$this->taskMapper,
+ $config
);
}