mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
test: Add tests for whether spreed is enabled
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
This commit is contained in:
parent
950a3f8d37
commit
c55cfc4367
1 changed files with 88 additions and 0 deletions
|
|
@ -132,4 +132,92 @@ class BrokerTest extends TestCase {
|
|||
$options
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsDisabledForUserNoBackend(): void {
|
||||
$this->coordinator->expects(self::once())
|
||||
->method('getRegistrationContext')
|
||||
->willReturn($this->createMock(RegistrationContext::class));
|
||||
|
||||
self::assertTrue(
|
||||
$this->broker->isDisabledForUser()
|
||||
);
|
||||
}
|
||||
|
||||
public static function dataIsDisabledForUser(): array {
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataIsDisabledForUser
|
||||
*/
|
||||
public function testIsDisabledForUser(bool $disabled): void {
|
||||
$fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
|
||||
$registrationContext = $this->createMock(RegistrationContext::class);
|
||||
$this->coordinator->expects(self::once())
|
||||
->method('getRegistrationContext')
|
||||
->willReturn($registrationContext);
|
||||
$registrationContext->expects(self::once())
|
||||
->method('getTalkBackendRegistration')
|
||||
->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
|
||||
$talkService = $this->createMock(ITalkBackend::class);
|
||||
$this->container->expects(self::once())
|
||||
->method('get')
|
||||
->with($fakeTalkServiceClass)
|
||||
->willReturn($talkService);
|
||||
$talkService->expects(self::once())
|
||||
->method('isDisabledForUser')
|
||||
->willReturn($disabled);
|
||||
|
||||
self::assertSame(
|
||||
$disabled,
|
||||
$this->broker->isDisabledForUser()
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsNotAllowedToCreateConversationsNoBackend(): void {
|
||||
$this->coordinator->expects(self::once())
|
||||
->method('getRegistrationContext')
|
||||
->willReturn($this->createMock(RegistrationContext::class));
|
||||
|
||||
self::assertTrue(
|
||||
$this->broker->isNotAllowedToCreateConversations()
|
||||
);
|
||||
}
|
||||
|
||||
public static function dataIsNotAllowedToCreateConversations(): array {
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataIsNotAllowedToCreateConversations
|
||||
*/
|
||||
public function testIsNotAllowedToCreateConversations(bool $notAllowed): void {
|
||||
$fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
|
||||
$registrationContext = $this->createMock(RegistrationContext::class);
|
||||
$this->coordinator->expects(self::once())
|
||||
->method('getRegistrationContext')
|
||||
->willReturn($registrationContext);
|
||||
$registrationContext->expects(self::once())
|
||||
->method('getTalkBackendRegistration')
|
||||
->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
|
||||
$talkService = $this->createMock(ITalkBackend::class);
|
||||
$this->container->expects(self::once())
|
||||
->method('get')
|
||||
->with($fakeTalkServiceClass)
|
||||
->willReturn($talkService);
|
||||
$talkService->expects(self::once())
|
||||
->method('isNotAllowedToCreateConversations')
|
||||
->willReturn($notAllowed);
|
||||
|
||||
self::assertSame(
|
||||
$notAllowed,
|
||||
$this->broker->isNotAllowedToCreateConversations()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue