From 75f4307fc8632a44a37fefec8ecd96275fe13b81 Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 09:55:41 +0200 Subject: [PATCH 1/8] Add is read checks/methods to extend the Message model --- src/Models/Message.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Models/Message.php b/src/Models/Message.php index df327b2..ec7da44 100644 --- a/src/Models/Message.php +++ b/src/Models/Message.php @@ -14,6 +14,7 @@ class Message public ?string $senderId; public string $text; public array $readBy; + public bool $isRead; public string $origin; public ?string $location; public array $custom; @@ -28,6 +29,7 @@ public function __construct(array $data) $this->conversationId = (string)$data['conversationId']; $this->text = $data['text']; $this->readBy = $data['readBy']; + $this->isRead = $this->checkIsRead($data); $this->origin = $data['origin']; $this->location = $data['location'] ?? null; $this->custom = $data['custom']; @@ -53,4 +55,18 @@ public function isSystemMessage(): bool { return $this->type == MessageType::SYSTEM; } + + public function isReadBy(string $userId): bool + { + if ($userId === $this->senderId) { + return true; + } + + return in_array($userId, $this->readBy, true); + } + + private function checkIsRead(array $data): bool + { + return !empty($data['readBy']); + } } From 50b33d10cd7f1fb7ab2831e11df176fb63db76fe Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 10:07:57 +0200 Subject: [PATCH 2/8] Add is read checks/methods to extend the Conversation model --- src/Models/Conversation.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Models/Conversation.php b/src/Models/Conversation.php index e2774db..6ef51fb 100644 --- a/src/Models/Conversation.php +++ b/src/Models/Conversation.php @@ -24,6 +24,8 @@ class Conversation public array $participants; + public bool $isLastMessageRead; + public int $createdAt; public function __construct(array $data) @@ -36,6 +38,7 @@ public function __construct(array $data) $this->custom = $data['custom'] ?? []; $this->lastMessage = isset($data['lastMessage']) ? new Message($data['lastMessage']) : null; $this->participants = $data['participants'] ?? []; + $this->isLastMessageRead = $this->checkIsLastMessageRead($data); $this->createdAt = $data['createdAt']; } @@ -47,4 +50,26 @@ public static function createManyFromArray(array $data): array } return $conversations; } + + public function isLastMessageReadBy(string $userId): bool + { + if ($userId === $this->senderId) { + return true; + } + + return in_array($userId, $this->readBy, true); + } + + public function unreadByPartisipants(): array + { + $readBy = [...$this->lastMessage->readBy, $this->senderId]; + $partisipants = array_keys($this->participants); + + return array_diff($partisipants, $readBy); + } + + private function checkIsLastMessageRead(array $data): bool + { + return !empty($data['lastMessage']['readBy']); + } } From 99743a358108428749879662e32360153ad9834c Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 10:34:26 +0200 Subject: [PATCH 3/8] Adding unreadBy methods. Clean up Conversation model --- src/Models/Conversation.php | 26 +++++--------------------- src/Models/Message.php | 8 ++++++++ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/Models/Conversation.php b/src/Models/Conversation.php index 6ef51fb..11c7d02 100644 --- a/src/Models/Conversation.php +++ b/src/Models/Conversation.php @@ -24,8 +24,6 @@ class Conversation public array $participants; - public bool $isLastMessageRead; - public int $createdAt; public function __construct(array $data) @@ -38,7 +36,6 @@ public function __construct(array $data) $this->custom = $data['custom'] ?? []; $this->lastMessage = isset($data['lastMessage']) ? new Message($data['lastMessage']) : null; $this->participants = $data['participants'] ?? []; - $this->isLastMessageRead = $this->checkIsLastMessageRead($data); $this->createdAt = $data['createdAt']; } @@ -51,25 +48,12 @@ public static function createManyFromArray(array $data): array return $conversations; } - public function isLastMessageReadBy(string $userId): bool + public function unreadBy(Message $message = null): array { - if ($userId === $this->senderId) { - return true; - } + $message ??= $this->lastMessage; + $readBy = [...$message->readBy, $message->senderId]; + $participants = array_keys($this->participants); - return in_array($userId, $this->readBy, true); - } - - public function unreadByPartisipants(): array - { - $readBy = [...$this->lastMessage->readBy, $this->senderId]; - $partisipants = array_keys($this->participants); - - return array_diff($partisipants, $readBy); - } - - private function checkIsLastMessageRead(array $data): bool - { - return !empty($data['lastMessage']['readBy']); + return array_diff($participants, $readBy); } } diff --git a/src/Models/Message.php b/src/Models/Message.php index ec7da44..82b7001 100644 --- a/src/Models/Message.php +++ b/src/Models/Message.php @@ -5,6 +5,7 @@ namespace CarAndClassic\TalkJS\Models; use CarAndClassic\TalkJS\Enumerations\MessageType; +use CarAndClassic\TalkJS\TalkJSClient; class Message { @@ -65,6 +66,13 @@ public function isReadBy(string $userId): bool return in_array($userId, $this->readBy, true); } + public function unreadBy(): array + { + $conversation = app(TalkJSClient::class)->conversations->find($this->conversationId); + + return $conversation->unreadBy($this); + } + private function checkIsRead(array $data): bool { return !empty($data['readBy']); From 924285b1c23516449bb369fd91b2d901663b0488 Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 10:51:32 +0200 Subject: [PATCH 4/8] Add Conversation unreadBy test --- src/Models/Conversation.php | 7 +++- tests/Feature/ConversationTest.php | 56 +++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/Models/Conversation.php b/src/Models/Conversation.php index 11c7d02..ea755db 100644 --- a/src/Models/Conversation.php +++ b/src/Models/Conversation.php @@ -48,9 +48,14 @@ public static function createManyFromArray(array $data): array return $conversations; } - public function unreadBy(Message $message = null): array + public function unreadBy(Message $message = null): array|null { $message ??= $this->lastMessage; + + if (is_null($message)) { + return null; + } + $readBy = [...$message->readBy, $message->senderId]; $participants = array_keys($this->participants); diff --git a/tests/Feature/ConversationTest.php b/tests/Feature/ConversationTest.php index c845756..25a7538 100644 --- a/tests/Feature/ConversationTest.php +++ b/tests/Feature/ConversationTest.php @@ -54,7 +54,7 @@ public function setUp(): void 'createdAt' => $createdAt, ]), 'participants' => [ - $this->userIds[0] => [ + $this->userIds[0] => [ 'access' => 'ReadWrite', 'notify' => true ], @@ -84,6 +84,38 @@ public function setUp(): void ] ], 'createdAt' => $createdAt + ], + [ + 'id' => 'testConversationId3', + 'subject' => 'Test Conversation 3', + 'topicId' => 'Test Topic 3', + 'photoUrl' => null, + 'welcomeMessages' => ['Test Welcome Message'], + 'custom' => ['test' => 'test'], + 'lastMessage' => new Message([ + 'id' => "test", + 'type' => "UserMessage", + 'conversationId' => "dev_test", + 'senderId' => $this->userIds[1], + 'text' => "This is the message copy", + 'readBy' => [], + 'origin' => "rest", + 'location' => null, + 'custom' => [], + 'attachment' => null, + 'createdAt' => $createdAt, + ]), + 'participants' => [ + $this->userIds[0] => [ + 'access' => 'ReadWrite', + 'notify' => true + ], + $this->userIds[1] => [ + 'access' => 'Read', + 'notify' => false + ] + ], + 'createdAt' => $createdAt ] ]; } @@ -267,4 +299,26 @@ public function testDelete(): void $this->assertInstanceOf(ConversationDeleted::class, $conversationDeleted); } + + public function testUnreadBy() + { + $api = $this->createApiWithMockHttpClient( + [ + new MockResponse( + json_encode(['data' => $this->conversations]), + ['response_headers' => $this->defaultMockResponseHeaders] + ) + ], + ConversationApi::class + ); + + $conversations = $api->get($this->defaultFilters); + $conversation1 = current($conversations); + $conversation2 = next($conversations); + $conversation3 = next($conversations); + + $this->assertEmpty($conversation1->unreadBy()); + $this->assertNull($conversation2->unreadBy()); + $this->assertEquals($conversation3->unreadBy(), ['TestConversationUserId1']); + } } From c54239b8000dbeec0c859ddd3f53c0407dfbf144 Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 12:30:04 +0200 Subject: [PATCH 5/8] Move to adding unit tests --- src/Models/Conversation.php | 9 +- src/Models/Message.php | 14 +-- tests/Feature/ConversationTest.php | 1 + tests/Feature/MessageTest.php | 1 + tests/Feature/UserTest.php | 1 + tests/{Feature => }/TestCase.php | 2 +- tests/Unit/ConversationTest.php | 135 +++++++++++++++++++++++++++++ tests/Unit/MessageTest.php | 103 ++++++++++++++++++++++ 8 files changed, 249 insertions(+), 17 deletions(-) rename tests/{Feature => }/TestCase.php (96%) create mode 100644 tests/Unit/ConversationTest.php create mode 100644 tests/Unit/MessageTest.php diff --git a/src/Models/Conversation.php b/src/Models/Conversation.php index ea755db..f198e0f 100644 --- a/src/Models/Conversation.php +++ b/src/Models/Conversation.php @@ -48,15 +48,14 @@ public static function createManyFromArray(array $data): array return $conversations; } - public function unreadBy(Message $message = null): array|null + public function unreadBy(): ?array { - $message ??= $this->lastMessage; - - if (is_null($message)) { + if ($this->lastMessage === null) { return null; } - $readBy = [...$message->readBy, $message->senderId]; + $readBy = $this->lastMessage->readBy; + $readBy[] = $this->lastMessage->senderId; $participants = array_keys($this->participants); return array_diff($participants, $readBy); diff --git a/src/Models/Message.php b/src/Models/Message.php index 82b7001..2d5c372 100644 --- a/src/Models/Message.php +++ b/src/Models/Message.php @@ -5,7 +5,6 @@ namespace CarAndClassic\TalkJS\Models; use CarAndClassic\TalkJS\Enumerations\MessageType; -use CarAndClassic\TalkJS\TalkJSClient; class Message { @@ -15,7 +14,6 @@ class Message public ?string $senderId; public string $text; public array $readBy; - public bool $isRead; public string $origin; public ?string $location; public array $custom; @@ -30,7 +28,6 @@ public function __construct(array $data) $this->conversationId = (string)$data['conversationId']; $this->text = $data['text']; $this->readBy = $data['readBy']; - $this->isRead = $this->checkIsRead($data); $this->origin = $data['origin']; $this->location = $data['location'] ?? null; $this->custom = $data['custom']; @@ -66,15 +63,10 @@ public function isReadBy(string $userId): bool return in_array($userId, $this->readBy, true); } - public function unreadBy(): array + public function isRead(): bool { - $conversation = app(TalkJSClient::class)->conversations->find($this->conversationId); + $unread = array_diff($this->readBy, [$this->senderId]); - return $conversation->unreadBy($this); - } - - private function checkIsRead(array $data): bool - { - return !empty($data['readBy']); + return !empty($unread); } } diff --git a/tests/Feature/ConversationTest.php b/tests/Feature/ConversationTest.php index 25a7538..099b1cf 100644 --- a/tests/Feature/ConversationTest.php +++ b/tests/Feature/ConversationTest.php @@ -14,6 +14,7 @@ use CarAndClassic\TalkJS\Events\ParticipationUpdated; use CarAndClassic\TalkJS\Models\Conversation; use CarAndClassic\TalkJS\Models\Message; +use CarAndClassic\TalkJS\Tests\TestCase; use Symfony\Component\HttpClient\Response\MockResponse; final class ConversationTest extends TestCase diff --git a/tests/Feature/MessageTest.php b/tests/Feature/MessageTest.php index 60eacea..1224ae3 100644 --- a/tests/Feature/MessageTest.php +++ b/tests/Feature/MessageTest.php @@ -10,6 +10,7 @@ use CarAndClassic\TalkJS\Events\MessageDeleted; use CarAndClassic\TalkJS\Events\MessageEdited; use CarAndClassic\TalkJS\Models\Message; +use CarAndClassic\TalkJS\Tests\TestCase; use Symfony\Component\HttpClient\Response\MockResponse; final class MessageTest extends TestCase diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index db14918..2c19b6a 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -8,6 +8,7 @@ use CarAndClassic\TalkJS\Events\UserCreatedOrUpdated; use CarAndClassic\TalkJS\Models\Conversation; use CarAndClassic\TalkJS\Models\User; +use CarAndClassic\TalkJS\Tests\TestCase; use Symfony\Component\HttpClient\Response\MockResponse; final class UserTest extends TestCase diff --git a/tests/Feature/TestCase.php b/tests/TestCase.php similarity index 96% rename from tests/Feature/TestCase.php rename to tests/TestCase.php index 998bcb7..0a90bd9 100644 --- a/tests/Feature/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace CarAndClassic\TalkJS\Tests\Feature; +namespace CarAndClassic\TalkJS\Tests; use CarAndClassic\TalkJS\Api\TalkJSApi; use PHPUnit\Framework\TestCase as BaseTestCase; diff --git a/tests/Unit/ConversationTest.php b/tests/Unit/ConversationTest.php new file mode 100644 index 0000000..327b35d --- /dev/null +++ b/tests/Unit/ConversationTest.php @@ -0,0 +1,135 @@ +userIds = [ + 'TestConversationUserId1', + 'TestConversationUserId2' + ]; + $this->conversations = [ + [ + 'id' => 'testConversationId1', + 'subject' => 'Test Conversation 1', + 'topicId' => 'Test Topic 1', + 'photoUrl' => null, + 'welcomeMessages' => ['Test Welcome Message'], + 'custom' => ['test' => 'test'], + 'lastMessage' => [ + 'id' => "test", + 'type' => "UserMessage", + 'conversationId' => "dev_test", + 'senderId' => $this->userIds[1], + 'text' => "This is the message copy", + 'readBy' => [ + $this->userIds[0], + ], + 'origin' => "rest", + 'location' => null, + 'custom' => [], + 'attachment' => null, + 'createdAt' => $createdAt, + ], + 'participants' => [ + $this->userIds[0] => [ + 'access' => 'ReadWrite', + 'notify' => true + ], + $this->userIds[1] => [ + 'access' => 'Read', + 'notify' => false + ] + ], + 'createdAt' => $createdAt + ], + [ + 'id' => 'testConversationId2', + 'subject' => 'Test Conversation 2', + 'topicId' => 'Test Topic 2', + 'photoUrl' => null, + 'welcomeMessages' => ['Test Welcome Message'], + 'custom' => ['test' => 'test'], + 'lastMessage' => null, + 'participants' => [ + $this->userIds[0] => [ + 'access' => 'ReadWrite', + 'notify' => true + ], + $this->userIds[1] => [ + 'access' => 'Read', + 'notify' => false + ] + ], + 'createdAt' => $createdAt + ], + [ + 'id' => 'testConversationId3', + 'subject' => 'Test Conversation 3', + 'topicId' => 'Test Topic 3', + 'photoUrl' => null, + 'welcomeMessages' => ['Test Welcome Message'], + 'custom' => ['test' => 'test'], + 'lastMessage' => [ + 'id' => "test", + 'type' => "UserMessage", + 'conversationId' => "dev_test", + 'senderId' => $this->userIds[1], + 'text' => "This is the message copy", + 'readBy' => [], + 'origin' => "rest", + 'location' => null, + 'custom' => [], + 'attachment' => null, + 'createdAt' => $createdAt, + ], + 'participants' => [ + $this->userIds[0] => [ + 'access' => 'ReadWrite', + 'notify' => true + ], + $this->userIds[1] => [ + 'access' => 'Read', + 'notify' => false + ] + ], + 'createdAt' => $createdAt + ] + ]; + } + + public function testCreateManyFromArray(): void + { + $conversations = Conversation::createManyFromArray($this->conversations); + + $this->assertIsArray($conversations); + + foreach ($conversations as $conversation) { + $this->assertInstanceOf(Conversation::class, $conversation); + } + } + + public function testUnreadBy() + { + $conversation1 = new Conversation($this->conversations[0]); + $conversation2 = new Conversation($this->conversations[1]); + $conversation3 = new Conversation($this->conversations[2]); + + $this->assertEmpty($conversation1->unreadBy()); + $this->assertNull($conversation2->unreadBy()); + $this->assertEquals($conversation3->unreadBy(), ['TestConversationUserId1']); + } +} diff --git a/tests/Unit/MessageTest.php b/tests/Unit/MessageTest.php new file mode 100644 index 0000000..90669b2 --- /dev/null +++ b/tests/Unit/MessageTest.php @@ -0,0 +1,103 @@ +conversationId = 'testConversationId'; + $this->senderId = 'testSenderId'; + $this->userIds = [ + 'TestConversationUserId1', + 'TestConversationUserId2' + ]; + $this->messages = [ + [ + 'id' => '1', // At time of writing results are returned descending + 'type' => MessageType::USER, + 'conversationId' => $this->conversationId, + 'senderId' => $this->senderId, + 'text' => 'Test User Message', + 'readBy' => [ + $this->userIds[0] + ], + 'origin' => 'rest', + 'location' => null, + 'custom' => ['test' => 'test'], + 'createdAt' => (time() + 1) * 1000, // At time of writing TalkJS returns timestamp in milliseconds + 'attachment' => null + ], + [ + 'id' => '2', + 'type' => MessageType::SYSTEM, + 'conversationId' => $this->conversationId, + 'senderId' => null, + 'text' => 'Test System Message', + 'readBy' => [], + 'origin' => 'rest', + 'location' => null, + 'custom' => ['test' => 'test'], + 'createdAt' => time() * 1000, + 'attachment' => null + ] + ]; + $this->message1 = new Message($this->messages[0]); + $this->message2 = new Message($this->messages[1]); + } + + public function testCreateManyFromArray(): void + { + $messages = Message::createManyFromArray($this->messages); + + $this->assertIsArray($messages); + + foreach ($messages as $message) { + $this->assertInstanceOf(Message::class, $message); + } + } + + public function testIsUserMessage(): void + { + $this->assertSame($this->message1->isUserMessage(), true); + $this->assertSame($this->message2->isUserMessage(), false); + } + + public function testIsSystemMessage(): void + { + $this->assertSame($this->message1->isSystemMessage(), false); + $this->assertSame($this->message2->isSystemMessage(), true); + } + + public function testIsReadBy(): void + { + $this->assertSame($this->message1->isReadBy($this->userIds[0]), true); + $this->assertSame($this->message1->isReadBy($this->userIds[1]), false); + $this->assertSame($this->message1->isReadBy($this->senderId), true); + $this->assertSame($this->message2->isReadBy($this->userIds[0]), false); + } + + public function testIsRead(): void + { + $this->assertSame($this->message1->isRead(), true); + $this->assertSame($this->message2->isRead(), false); + } +} From f7878cbdfac4df317b823f89001639197c01ee44 Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 12:35:38 +0200 Subject: [PATCH 6/8] Remove feature test that was moved to unit test --- tests/Feature/ConversationTest.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tests/Feature/ConversationTest.php b/tests/Feature/ConversationTest.php index 099b1cf..27075cb 100644 --- a/tests/Feature/ConversationTest.php +++ b/tests/Feature/ConversationTest.php @@ -300,26 +300,4 @@ public function testDelete(): void $this->assertInstanceOf(ConversationDeleted::class, $conversationDeleted); } - - public function testUnreadBy() - { - $api = $this->createApiWithMockHttpClient( - [ - new MockResponse( - json_encode(['data' => $this->conversations]), - ['response_headers' => $this->defaultMockResponseHeaders] - ) - ], - ConversationApi::class - ); - - $conversations = $api->get($this->defaultFilters); - $conversation1 = current($conversations); - $conversation2 = next($conversations); - $conversation3 = next($conversations); - - $this->assertEmpty($conversation1->unreadBy()); - $this->assertNull($conversation2->unreadBy()); - $this->assertEquals($conversation3->unreadBy(), ['TestConversationUserId1']); - } } From 959590618ed42f259f044022b24ca9b1bcec605f Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 12:38:40 +0200 Subject: [PATCH 7/8] Change global vars to local where needed --- tests/Unit/ConversationTest.php | 22 ++++++++++------------ tests/Unit/MessageTest.php | 8 +++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/Unit/ConversationTest.php b/tests/Unit/ConversationTest.php index 327b35d..7bc7eb8 100644 --- a/tests/Unit/ConversationTest.php +++ b/tests/Unit/ConversationTest.php @@ -9,15 +9,13 @@ final class ConversationTest extends TestCase { - private array $userIds; - private array $conversations; public function setUp(): void { parent::setUp(); $createdAt = time() * 1000; - $this->userIds = [ + $userIds = [ 'TestConversationUserId1', 'TestConversationUserId2' ]; @@ -33,10 +31,10 @@ public function setUp(): void 'id' => "test", 'type' => "UserMessage", 'conversationId' => "dev_test", - 'senderId' => $this->userIds[1], + 'senderId' => $userIds[1], 'text' => "This is the message copy", 'readBy' => [ - $this->userIds[0], + $userIds[0], ], 'origin' => "rest", 'location' => null, @@ -45,11 +43,11 @@ public function setUp(): void 'createdAt' => $createdAt, ], 'participants' => [ - $this->userIds[0] => [ + $userIds[0] => [ 'access' => 'ReadWrite', 'notify' => true ], - $this->userIds[1] => [ + $userIds[1] => [ 'access' => 'Read', 'notify' => false ] @@ -65,11 +63,11 @@ public function setUp(): void 'custom' => ['test' => 'test'], 'lastMessage' => null, 'participants' => [ - $this->userIds[0] => [ + $userIds[0] => [ 'access' => 'ReadWrite', 'notify' => true ], - $this->userIds[1] => [ + $userIds[1] => [ 'access' => 'Read', 'notify' => false ] @@ -87,7 +85,7 @@ public function setUp(): void 'id' => "test", 'type' => "UserMessage", 'conversationId' => "dev_test", - 'senderId' => $this->userIds[1], + 'senderId' => $userIds[1], 'text' => "This is the message copy", 'readBy' => [], 'origin' => "rest", @@ -97,11 +95,11 @@ public function setUp(): void 'createdAt' => $createdAt, ], 'participants' => [ - $this->userIds[0] => [ + $userIds[0] => [ 'access' => 'ReadWrite', 'notify' => true ], - $this->userIds[1] => [ + $userIds[1] => [ 'access' => 'Read', 'notify' => false ] diff --git a/tests/Unit/MessageTest.php b/tests/Unit/MessageTest.php index 90669b2..3c16b12 100644 --- a/tests/Unit/MessageTest.php +++ b/tests/Unit/MessageTest.php @@ -10,8 +10,6 @@ final class MessageTest extends TestCase { - private string $conversationId; - private string $senderId; private array $messages; @@ -24,7 +22,7 @@ protected function setUp(): void { parent::setUp(); - $this->conversationId = 'testConversationId'; + $conversationId = 'testConversationId'; $this->senderId = 'testSenderId'; $this->userIds = [ 'TestConversationUserId1', @@ -34,7 +32,7 @@ protected function setUp(): void [ 'id' => '1', // At time of writing results are returned descending 'type' => MessageType::USER, - 'conversationId' => $this->conversationId, + 'conversationId' => $conversationId, 'senderId' => $this->senderId, 'text' => 'Test User Message', 'readBy' => [ @@ -49,7 +47,7 @@ protected function setUp(): void [ 'id' => '2', 'type' => MessageType::SYSTEM, - 'conversationId' => $this->conversationId, + 'conversationId' => $conversationId, 'senderId' => null, 'text' => 'Test System Message', 'readBy' => [], From 2c9f51e133c3dc0e8b4fd682db9bcfb74ab82738 Mon Sep 17 00:00:00 2001 From: Wesley Martin Date: Wed, 7 Dec 2022 16:14:06 +0200 Subject: [PATCH 8/8] Add missing return type. Remove waistful new lines --- tests/Feature/ConversationTest.php | 1 - tests/Feature/MessageTest.php | 2 -- tests/Feature/UserTest.php | 2 -- tests/TestCase.php | 1 - tests/Unit/ConversationTest.php | 2 +- tests/Unit/MessageTest.php | 3 --- 6 files changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/Feature/ConversationTest.php b/tests/Feature/ConversationTest.php index 27075cb..bb3df7f 100644 --- a/tests/Feature/ConversationTest.php +++ b/tests/Feature/ConversationTest.php @@ -20,7 +20,6 @@ final class ConversationTest extends TestCase { private array $userIds; - private array $conversations; public function setUp(): void diff --git a/tests/Feature/MessageTest.php b/tests/Feature/MessageTest.php index 1224ae3..06d604b 100644 --- a/tests/Feature/MessageTest.php +++ b/tests/Feature/MessageTest.php @@ -16,9 +16,7 @@ final class MessageTest extends TestCase { private string $conversationId; - private string $senderId; - private array $messages; protected function setUp(): void diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 2c19b6a..8525083 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -14,9 +14,7 @@ final class UserTest extends TestCase { private string $userId; - private array $userDetails; - private array $userConversations; protected function setUp(): void diff --git a/tests/TestCase.php b/tests/TestCase.php index 0a90bd9..01de248 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -12,7 +12,6 @@ abstract class TestCase extends BaseTestCase { protected array $defaultMockResponseHeaders; - protected array $defaultFilters; protected function setUp(): void diff --git a/tests/Unit/ConversationTest.php b/tests/Unit/ConversationTest.php index 7bc7eb8..7835d6a 100644 --- a/tests/Unit/ConversationTest.php +++ b/tests/Unit/ConversationTest.php @@ -120,7 +120,7 @@ public function testCreateManyFromArray(): void } } - public function testUnreadBy() + public function testUnreadBy(): void { $conversation1 = new Conversation($this->conversations[0]); $conversation2 = new Conversation($this->conversations[1]); diff --git a/tests/Unit/MessageTest.php b/tests/Unit/MessageTest.php index 3c16b12..a40253c 100644 --- a/tests/Unit/MessageTest.php +++ b/tests/Unit/MessageTest.php @@ -11,11 +11,8 @@ final class MessageTest extends TestCase { private string $senderId; - private array $messages; - private Message $message1; - private Message $message2; protected function setUp(): void