Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2021-04-14 09:45:07 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2021-04-16 14:56:28 +0300
commit808e5890355a9f719bd6db5f74c3514a07140963 (patch)
treeedd1ca1f4a5e8c3a1ba31f9d1c7aff54351fc459 /tests
parent403388269a15c11e06c8d8585fefec4e78aa343b (diff)
Allow registering NotifierServices trough IBootstrap
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Notification/ManagerTest.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php
index cd0d4bd36c8..b1201d31c42 100644
--- a/tests/lib/Notification/ManagerTest.php
+++ b/tests/lib/Notification/ManagerTest.php
@@ -21,6 +21,9 @@
namespace Test\Notification;
+use OC\AppFramework\Bootstrap\Coordinator;
+use OC\AppFramework\Bootstrap\RegistrationContext;
+use OC\AppFramework\Bootstrap\ServiceRegistration;
use OC\Notification\Manager;
use OCP\ILogger;
use OCP\Notification\IManager;
@@ -37,12 +40,23 @@ class ManagerTest extends TestCase {
protected $validator;
/** @var ILogger|MockObject */
protected $logger;
+ /** @var Coordinator|MockObject */
+ protected $coordinator;
+ /** @var RegistrationContext|MockObject */
+ protected $registrationContext;
protected function setUp(): void {
parent::setUp();
+
$this->validator = $this->createMock(IValidator::class);
$this->logger = $this->createMock(ILogger::class);
- $this->manager = new Manager($this->validator, $this->logger);
+
+ $this->registrationContext = $this->createMock(RegistrationContext::class);
+ $this->coordinator = $this->createMock(Coordinator::class);
+ $this->coordinator->method('getRegistrationContext')
+ ->willReturn($this->registrationContext);
+
+ $this->manager = new Manager($this->validator, $this->logger, $this->coordinator);
}
public function testRegisterApp() {
@@ -79,6 +93,16 @@ class ManagerTest extends TestCase {
$this->assertCount(2, self::invokePrivate($this->manager, 'getNotifiers'));
}
+ public function testRegisterNotifierBootstrap() {
+ $this->registrationContext->method('getNotifierServices')
+ ->willReturn([
+ new ServiceRegistration('app', DummyNotifier::class),
+ ]);
+
+ $this->assertCount(1, self::invokePrivate($this->manager, 'getNotifiers'));
+ $this->assertCount(1, self::invokePrivate($this->manager, 'getNotifiers'));
+ }
+
public function testRegisterNotifierInvalid() {
$this->manager->registerNotifierService(DummyApp::class);
@@ -105,6 +129,7 @@ class ManagerTest extends TestCase {
->setConstructorArgs([
$this->validator,
$this->logger,
+ $this->coordinator,
])
->setMethods(['getApps'])
->getMock();
@@ -132,6 +157,7 @@ class ManagerTest extends TestCase {
->setConstructorArgs([
$this->validator,
$this->logger,
+ $this->coordinator,
])
->setMethods(['getApps'])
->getMock();
@@ -152,6 +178,7 @@ class ManagerTest extends TestCase {
->setConstructorArgs([
$this->validator,
$this->logger,
+ $this->coordinator,
])
->setMethods(['getApps'])
->getMock();
@@ -173,6 +200,7 @@ class ManagerTest extends TestCase {
->setConstructorArgs([
$this->validator,
$this->logger,
+ $this->coordinator,
])
->setMethods(['getApps'])
->getMock();