summaryrefslogtreecommitdiffstats
path: root/tests/lib
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/lib
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/lib')
-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
5 files changed, 123 insertions, 300 deletions
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
);
}