Skip to content

Commit f341dca

Browse files
committed
update tests
1 parent ced7b94 commit f341dca

6 files changed

Lines changed: 44 additions & 89 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- laravel: 12.*
3838
testbench: 10.*
3939
dbal: ^4.2
40+
- laravel: 13.*
41+
testbench: 11.*
42+
dbal: ^4.2
4043
exclude:
4144
- laravel: 6.*
4245
php-versions: 8.1

phpunit.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
55
backupGlobals="false"
6-
backupStaticAttributes="false"
76
bootstrap="vendor/autoload.php"
87
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
128
processIsolation="false"
139
stopOnFailure="false"
1410
failOnWarning="true"
1511
failOnRisky="true"
1612
failOnEmptyTestSuite="true"
17-
beStrictAboutOutputDuringTests="true"
18-
verbose="true"
1913
>
2014
<testsuites>
2115
<testsuite name="Messenger Test Suite">

tests/CustomModelsTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,28 @@
1212

1313
class CustomModelsTest extends TestCase
1414
{
15-
/** @test */
16-
public function it_can_use_custom_message_model(): void
15+
public function test_it_can_use_custom_message_model(): void
1716
{
1817
$this->setMessageCustomModel();
1918
$this->assertEquals(CustomMessage::class, get_class(Models::message()));
2019
$this->unsetMessageCustomModel();
2120
}
2221

23-
/** @test */
24-
public function it_can_use_custom_participant_model(): void
22+
public function test_it_can_use_custom_participant_model(): void
2523
{
2624
$this->setParticipantCustomModel();
2725
$this->assertEquals(CustomParticipant::class, get_class(Models::participant()));
2826
$this->unsetParticipantCustomModel();
2927
}
3028

31-
/** @test */
32-
public function it_can_use_custom_thread_model(): void
29+
public function test_it_can_use_custom_thread_model(): void
3330
{
3431
$this->setThreadCustomModel();
3532
$this->assertEquals(CustomThread::class, get_class(Models::thread()));
3633
$this->unsetThreadCustomModel();
3734
}
3835

39-
/** @test */
40-
public function it_can_use_custom_table(): void
36+
public function test_it_can_use_custom_table(): void
4137
{
4238
$this->setMessageCustomModel();
4339
$this->setMessageCustomTable();
@@ -48,8 +44,7 @@ public function it_can_use_custom_table(): void
4844
$this->unsetMessageCustomTable();
4945
}
5046

51-
/** @test */
52-
public function it_should_return_custom_name_when_not_available(): void
47+
public function test_it_should_return_custom_name_when_not_available(): void
5348
{
5449
$modelName = 'ModelNotFound';
5550

tests/EloquentMessageTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
class EloquentMessageTest extends TestCase
66
{
7-
/** @test */
8-
public function it_should_get_the_recipients_of_a_message(): void
7+
public function test_it_should_get_the_recipients_of_a_message(): void
98
{
109
$message = $this->messageFactory();
1110
$thread = $this->threadFactory();

tests/EloquentThreadTest.php

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ protected static function getMethod($name): ReflectionMethod
3131
return $method;
3232
}
3333

34-
/** @test */
35-
public function search_specific_thread_by_subject(): void
34+
public function test_search_specific_thread_by_subject(): void
3635
{
3736
$this->threadFactory(['id' => 1, 'subject' => 'first subject']);
3837
$this->threadFactory(['id' => 2, 'subject' => 'second subject']);
@@ -44,8 +43,7 @@ public function search_specific_thread_by_subject(): void
4443
$this->assertSame('first subject', $threads->first()->subject);
4544
}
4645

47-
/** @test */
48-
public function search_threads_by_subject(): void
46+
public function test_search_threads_by_subject(): void
4947
{
5048
$this->threadFactory(['id' => 1, 'subject' => 'first subject']);
5149
$this->threadFactory(['id' => 2, 'subject' => 'second subject']);
@@ -61,8 +59,7 @@ public function search_threads_by_subject(): void
6159
$this->assertSame('second subject', $threads->last()->subject);
6260
}
6361

64-
/** @test */
65-
public function it_should_create_a_new_thread(): void
62+
public function test_it_should_create_a_new_thread(): void
6663
{
6764
$thread = $this->threadFactory();
6865
$this->assertSame('Sample thread', $thread->subject);
@@ -71,8 +68,7 @@ public function it_should_create_a_new_thread(): void
7168
$this->assertSame('Second sample thread', $thread->subject);
7269
}
7370

74-
/** @test */
75-
public function it_should_return_the_latest_message(): void
71+
public function test_it_should_return_the_latest_message(): void
7672
{
7773
$oldMessage = $this->messageFactory([
7874
'created_at' => Carbon::yesterday(),
@@ -88,8 +84,7 @@ public function it_should_return_the_latest_message(): void
8884
$this->assertSame($newMessage->body, $thread->latestMessage->body);
8985
}
9086

91-
/** @test */
92-
public function it_should_return_all_threads(): void
87+
public function test_it_should_return_all_threads(): void
9388
{
9489
$threadCount = random_int(5, 20);
9590

@@ -102,8 +97,7 @@ public function it_should_return_all_threads(): void
10297
$this->assertCount($threadCount, $threads);
10398
}
10499

105-
/** @test */
106-
public function it_should_get_all_thread_participants(): void
100+
public function test_it_should_get_all_thread_participants(): void
107101
{
108102
$thread = $this->threadFactory();
109103
$participantIds = $thread->participantsUserIds();
@@ -126,8 +120,7 @@ public function it_should_get_all_thread_participants(): void
126120
$this->assertIsArray($participantIds);
127121
}
128122

129-
/** @test */
130-
public function it_should_get_all_threads_for_a_user(): void
123+
public function test_it_should_get_all_threads_for_a_user(): void
131124
{
132125
$userId = 1;
133126

@@ -143,8 +136,7 @@ public function it_should_get_all_threads_for_a_user(): void
143136
$this->assertCount(2, $threads);
144137
}
145138

146-
/** @test */
147-
public function it_should_get_all_user_entities_for_a_thread(): void
139+
public function test_it_should_get_all_user_entities_for_a_thread(): void
148140
{
149141
$this->seedUsersTable();
150142

@@ -158,8 +150,7 @@ public function it_should_get_all_user_entities_for_a_thread(): void
158150
$this->assertArrayHasKey(2, $threadUserIds);
159151
}
160152

161-
/** @test */
162-
public function it_should_get_all_threads_for_a_user_with_new_messages(): void
153+
public function test_it_should_get_all_threads_for_a_user_with_new_messages(): void
163154
{
164155
$userId = 1;
165156

@@ -175,8 +166,7 @@ public function it_should_get_all_threads_for_a_user_with_new_messages(): void
175166
$this->assertCount(1, $threads);
176167
}
177168

178-
/** @test */
179-
public function it_should_get_all_threads_shared_by_specified_users(): void
169+
public function test_it_should_get_all_threads_shared_by_specified_users(): void
180170
{
181171
$userId = 1;
182172
$userId2 = 2;
@@ -192,8 +182,7 @@ public function it_should_get_all_threads_shared_by_specified_users(): void
192182
$this->assertCount(1, $threads);
193183
}
194184

195-
/** @test **/
196-
public function it_should_get_thread_between_participants(): void
185+
public function test_it_should_get_thread_between_participants(): void
197186
{
198187
$participant_1 = 1;
199188
$participant_2 = 2;
@@ -222,8 +211,7 @@ public function it_should_get_thread_between_participants(): void
222211
$this->assertCount(3, $threads_2->get());
223212
}
224213

225-
/** @test **/
226-
public function it_should_get_thread_between_only_participants(): void
214+
public function test_it_should_get_thread_between_only_participants(): void
227215
{
228216
$participant_1 = $this->participantFactory(['user_id' => 1]);
229217
$participant_2 = $this->participantFactory(['user_id' => 2]);
@@ -245,8 +233,7 @@ public function it_should_get_thread_between_only_participants(): void
245233
$this->assertCount(1, $threads_2->get());
246234
}
247235

248-
/** @test */
249-
public function it_should_add_a_participant_to_a_thread(): void
236+
public function test_it_should_add_a_participant_to_a_thread(): void
250237
{
251238
$participant = 1;
252239

@@ -257,8 +244,7 @@ public function it_should_add_a_participant_to_a_thread(): void
257244
$this->assertSame(1, $thread->participants()->count());
258245
}
259246

260-
/** @test */
261-
public function it_should_add_participants_to_a_thread_with_array(): void
247+
public function test_it_should_add_participants_to_a_thread_with_array(): void
262248
{
263249
$participants = [1, 2, 3];
264250

@@ -269,8 +255,7 @@ public function it_should_add_participants_to_a_thread_with_array(): void
269255
$this->assertSame(3, $thread->participants()->count());
270256
}
271257

272-
/** @test */
273-
public function it_should_add_participants_to_a_thread_with_arguments(): void
258+
public function test_it_should_add_participants_to_a_thread_with_arguments(): void
274259
{
275260
$thread = $this->threadFactory();
276261

@@ -279,8 +264,7 @@ public function it_should_add_participants_to_a_thread_with_arguments(): void
279264
$this->assertSame(2, $thread->participants()->count());
280265
}
281266

282-
/** @test */
283-
public function it_should_mark_the_participant_as_read(): void
267+
public function test_it_should_mark_the_participant_as_read(): void
284268
{
285269
$userId = 1;
286270
$last_read = Carbon::yesterday();
@@ -294,8 +278,7 @@ public function it_should_mark_the_participant_as_read(): void
294278
$this->assertNotSame($thread->getParticipantFromUser($userId)->last_read, $last_read);
295279
}
296280

297-
/** @test */
298-
public function it_should_see_if_thread_is_unread_by_user(): void
281+
public function test_it_should_see_if_thread_is_unread_by_user(): void
299282
{
300283
$userId = 1;
301284

@@ -312,8 +295,7 @@ public function it_should_see_if_thread_is_unread_by_user(): void
312295
$this->assertTrue($thread2->isUnread($userId));
313296
}
314297

315-
/** @test */
316-
public function it_should_get_a_participant_from_userid(): void
298+
public function test_it_should_get_a_participant_from_userid(): void
317299
{
318300
$userId = 1;
319301

@@ -326,8 +308,7 @@ public function it_should_get_a_participant_from_userid(): void
326308
$this->assertInstanceOf(Participant::class, $newParticipant);
327309
}
328310

329-
/** @test */
330-
public function it_should_throw_an_exception_when_participant_is_not_found(): void
311+
public function test_it_should_throw_an_exception_when_participant_is_not_found(): void
331312
{
332313
try {
333314
$thread = $this->threadFactory();
@@ -342,8 +323,7 @@ public function it_should_throw_an_exception_when_participant_is_not_found(): vo
342323
$this->fail('ModelNotFoundException was not called.');
343324
}
344325

345-
/** @test */
346-
public function it_should_activate_all_deleted_participants(): void
326+
public function test_it_should_activate_all_deleted_participants(): void
347327
{
348328
$deleted_at = Carbon::yesterday();
349329
$thread = $this->threadFactory();
@@ -363,8 +343,7 @@ public function it_should_activate_all_deleted_participants(): void
363343
$this->assertSame(3, $participants->count());
364344
}
365345

366-
/** @test */
367-
public function it_should_generate_participant_select_string(): void
346+
public function test_it_should_generate_participant_select_string(): void
368347
{
369348
$method = self::getMethod('createSelectString');
370349
$thread = new Thread();
@@ -390,8 +369,7 @@ public function it_should_generate_participant_select_string(): void
390369
}
391370
}
392371

393-
/** @test */
394-
public function it_should_get_participants_string(): void
372+
public function test_it_should_get_participants_string(): void
395373
{
396374
$this->seedUsersTable();
397375

@@ -413,8 +391,7 @@ public function it_should_get_participants_string(): void
413391
$this->assertSame('adam@test.com, taylor@test.com', $string);
414392
}
415393

416-
/** @test */
417-
public function it_should_check_users_and_participants(): void
394+
public function test_it_should_check_users_and_participants(): void
418395
{
419396
$thread = $this->threadFactory();
420397

@@ -428,8 +405,7 @@ public function it_should_check_users_and_participants(): void
428405
$this->assertFalse($thread->hasParticipant(3));
429406
}
430407

431-
/** @test */
432-
public function it_should_remove_a_single_participant(): void
408+
public function test_it_should_remove_a_single_participant(): void
433409
{
434410
$thread = $this->threadFactory();
435411

@@ -443,8 +419,7 @@ public function it_should_remove_a_single_participant(): void
443419
$this->assertSame(1, $thread->participants()->count());
444420
}
445421

446-
/** @test */
447-
public function it_should_remove_a_group_of_participants_with_array(): void
422+
public function test_it_should_remove_a_group_of_participants_with_array(): void
448423
{
449424
$thread = $this->threadFactory();
450425

@@ -458,8 +433,7 @@ public function it_should_remove_a_group_of_participants_with_array(): void
458433
$this->assertSame(0, $thread->participants()->count());
459434
}
460435

461-
/** @test */
462-
public function it_should_remove_a_group_of_participants_with_arguments(): void
436+
public function test_it_should_remove_a_group_of_participants_with_arguments(): void
463437
{
464438
$thread = $this->threadFactory();
465439

@@ -473,8 +447,7 @@ public function it_should_remove_a_group_of_participants_with_arguments(): void
473447
$this->assertSame(0, $thread->participants()->count());
474448
}
475449

476-
/** @test */
477-
public function it_should_get_all_unread_messages_for_user(): void
450+
public function test_it_should_get_all_unread_messages_for_user(): void
478451
{
479452
$thread = $this->threadFactory();
480453

@@ -510,8 +483,7 @@ public function it_should_get_all_unread_messages_for_user(): void
510483
$this->assertSame('Message 2', $secondParticipantUnreadMessages->first()->body);
511484
}
512485

513-
/** @test */
514-
public function it_should_get_all_unread_messages_for_user_when_dates_not_set(): void
486+
public function test_it_should_get_all_unread_messages_for_user_when_dates_not_set(): void
515487
{
516488
$thread = $this->threadFactory();
517489

@@ -547,16 +519,14 @@ public function it_should_get_all_unread_messages_for_user_when_dates_not_set():
547519
$this->assertSame('Message 2', $secondParticipantUnreadMessages->first()->body);
548520
}
549521

550-
/** @test */
551-
public function it_should_return_empty_collection_when_user_not_participant(): void
522+
public function test_it_should_return_empty_collection_when_user_not_participant(): void
552523
{
553524
$thread = $this->threadFactory();
554525

555526
$this->assertSame(0, $thread->userUnreadMessagesCount(1));
556527
}
557528

558-
/** @test */
559-
public function it_should_get_the_creator_of_a_thread(): void
529+
public function test_it_should_get_the_creator_of_a_thread(): void
560530
{
561531
$this->seedUsersTable();
562532

@@ -578,11 +548,9 @@ public function it_should_get_the_creator_of_a_thread(): void
578548
}
579549

580550
/**
581-
* @test
582-
*
583551
* TODO: Need to get real creator of the thread without messages in future versions.
584552
*/
585-
public function it_should_get_the_null_creator_of_a_thread_without_messages(): void
553+
public function test_it_should_get_the_null_creator_of_a_thread_without_messages(): void
586554
{
587555
$thread = $this->threadFactory();
588556

0 commit comments

Comments
 (0)