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

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2021-09-29 14:38:18 +0300
committerVitor Mattos <vitor@php.rio>2021-09-29 15:36:04 +0300
commita0082eda6490739760652517ab2136b23da8c243 (patch)
tree6019166ea828f6f2673bb06bdd377dbd2e88e0ac /tests
parente89466930fff3c543a9b7630750ab8e99a5b5432 (diff)
Tests
Signed-off-by: Vitor Mattos <vitor@php.rio> Update tests/php/Chat/ChatManagerTest.php Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/php/Chat/ChatManagerTest.php83
-rw-r--r--tests/php/Controller/ChatControllerTest.php4
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/php/Chat/ChatManagerTest.php b/tests/php/Chat/ChatManagerTest.php
index ea58a8b59..a8e40c05f 100644
--- a/tests/php/Chat/ChatManagerTest.php
+++ b/tests/php/Chat/ChatManagerTest.php
@@ -27,6 +27,7 @@ namespace OCA\Talk\Tests\php\Chat;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Chat\Notifier;
+use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
@@ -433,4 +434,86 @@ class ChatManagerTest extends TestCase {
);
$manager->clearHistory($chat, 'users', 'admin');
}
+
+ public function dataSearchIsPartOfConversationNameOrAtAll(): array {
+ return [
+ ['a', 'test', true],
+ ['h', 'test', true],
+ ['A', 'test', false],
+ ['H', 'test', false],
+ ['T', 'test', true],
+ ['t', 'test', true],
+ ['notbeginingall', 'test', false],
+ ['notbegininghere', 'test', false],
+ ['notbeginingtest', 'test', false]
+ ];
+ }
+
+ /**
+ * @dataProvider dataSearchIsPartOfConversationNameOrAtAll
+ */
+ public function testSearchIsPartOfConversationNameOrAtAll(string $search, string $roomDisplayName, bool $expected): void {
+ $actual = self::invokePrivate($this->chatManager, 'searchIsPartOfConversationNameOrAtAll', [$search, $roomDisplayName]);
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function dataAddConversationNotify(): array {
+ return [
+ [
+ '',
+ ['getType' => Room::TYPE_ONE_TO_ONE],
+ [],
+ []
+ ],
+ [
+ '',
+ ['getDisplayName' => 'test'],
+ ['getAttendee' => Attendee::fromRow([
+ 'actor_type' => Attendee::ACTOR_USERS,
+ 'actor_id' => 'user',
+ ])],
+ [['id' => 'all', 'label' => 'test', 'source' => 'calls']]
+ ],
+ [
+ 'all',
+ ['getDisplayName' => 'test'],
+ ['getAttendee' => Attendee::fromRow([
+ 'actor_type' => Attendee::ACTOR_USERS,
+ 'actor_id' => 'user',
+ ])],
+ [['id' => 'all', 'label' => 'test', 'source' => 'calls']]
+ ],
+ [
+ 'here',
+ ['getDisplayName' => 'test'],
+ ['getAttendee' => Attendee::fromRow([
+ 'actor_type' => Attendee::ACTOR_GUESTS,
+ 'actor_id' => 'guest',
+ ])],
+ [['id' => 'all', 'label' => 'test', 'source' => 'calls']]
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider dataAddConversationNotify
+ */
+ public function testAddConversationNotify($search, $roomMocks, $participantMocks, $expected) {
+ $room = $this->createMock(Room::class);
+ foreach ($roomMocks as $method => $return) {
+ $room->expects($this->once())
+ ->method($method)
+ ->willReturn($return);
+ }
+
+ $participant = $this->createMock(Participant::class);
+ foreach ($participantMocks as $method => $return) {
+ $participant->expects($this->once())
+ ->method($method)
+ ->willReturn($return);
+ }
+
+ $actual = $this->chatManager->addConversationNotify([], $search, $room, $participant);
+ $this->assertEquals($expected, $actual);
+ }
}
diff --git a/tests/php/Controller/ChatControllerTest.php b/tests/php/Controller/ChatControllerTest.php
index 449b430e3..236cc5d7b 100644
--- a/tests/php/Controller/ChatControllerTest.php
+++ b/tests/php/Controller/ChatControllerTest.php
@@ -1075,6 +1075,10 @@ class ChatControllerTest extends TestCase {
->method('asArray')
->willReturn($result);
+ $this->chatManager->expects($this->once())
+ ->method('addConversationNotify')
+ ->willReturnArgument(0);
+
$this->controller->setRoom($this->room);
$this->controller->setParticipant($participant);
$response = $this->controller->mentions($search, $limit);