Skip to content

Commit fc9e943

Browse files
committed
Merge branch 'master' into v2
2 parents 9cab074 + 67903c0 commit fc9e943

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: cmgmyr

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
language: php
22

33
php:
4-
- 7.1
54
- 7.2
65
- 7.3
6+
- 7.4
77

88
matrix:
99
include:
10-
- php: 7.1
10+
- php: 7.2
1111
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
1212
allow_failures:
1313
- php: nightly

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^7.1.3",
16-
"illuminate/config": "^5.5|^6.0|^7.0",
17-
"illuminate/support": "^5.5|^6.0|^7.0",
18-
"illuminate/database": "^5.5|^6.0|^7.0"
15+
"php": "^7.2",
16+
"illuminate/config": "^5.5|^6.0|^7.0|^8.0",
17+
"illuminate/support": "^5.5|^6.0|^7.0|^8.0",
18+
"illuminate/database": "^5.5|^6.0|^7.0|^8.0"
1919
},
2020
"require-dev": {
2121
"adamwathan/faktory": "0.3.*",
2222
"friendsofphp/php-cs-fixer": "^2.5",
23-
"orchestra/testbench": "^3.0|^4.0|^5.0",
24-
"phpunit/phpunit": "^7.0"
23+
"orchestra/testbench": "^3.0|^4.0|^5.0|^6.0",
24+
"phpunit/phpunit": "^8.0"
2525
},
2626
"autoload": {
2727
"psr-4": {

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[![Latest Version](https://img.shields.io/github/release/cmgmyr/laravel-messenger.svg?style=flat-square)](https://github.com/cmgmyr/laravel-messenger/releases)
55
[![Total Downloads](https://img.shields.io/packagist/dt/cmgmyr/messenger.svg?style=flat-square)](https://packagist.org/packages/cmgmyr/messenger)
66
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
7-
[![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/cmgmyr)
87

98
# Laravel Messenger
109
This package will allow you to add a full user messaging system into your Laravel application.

src/Models/Thread.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,14 @@ public function getParticipantFromUser($userId)
301301
}
302302

303303
/**
304-
* Restores all participants within a thread that has a new message.
304+
* Restores only trashed participants within a thread that has a new message.
305+
* Others are already active participiants.
305306
*
306307
* @return void
307308
*/
308309
public function activateAllParticipants()
309310
{
310-
$participants = $this->participants()->withTrashed()->get();
311+
$participants = $this->participants()->onlyTrashed()->get();
311312
foreach ($participants as $participant) {
312313
$participant->restore();
313314
}

tests/EloquentThreadTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Cmgmyr\Messenger\Models\Participant;
77
use Cmgmyr\Messenger\Models\Thread;
88
use Illuminate\Database\Eloquent\Model as Eloquent;
9+
use Illuminate\Database\Eloquent\ModelNotFoundException;
910
use Illuminate\Support\Carbon;
1011
use ReflectionClass;
1112

@@ -126,7 +127,7 @@ public function it_should_get_all_thread_participants()
126127
$this->assertCount(4, $participantIds);
127128
$this->assertEquals(999, end($participantIds));
128129

129-
$this->assertInternalType('array', $participantIds);
130+
$this->assertIsArray($participantIds);
130131
}
131132

132133
/** @test */
@@ -154,8 +155,9 @@ public function it_should_get_all_user_entities_for_a_thread()
154155
$user_2 = $this->faktory->build('participant', ['user_id' => 2]);
155156
$thread->participants()->saveMany([$user_1, $user_2]);
156157

157-
$threadUserIds = $thread->users()->get()->pluck('id')->toArray();
158-
$this->assertArraySubset([1, 2], $threadUserIds);
158+
$threadUserIds = $thread->users()->get()->pluck('id')->values()->flip();
159+
$this->assertArrayHasKey(1, $threadUserIds);
160+
$this->assertArrayHasKey(2, $threadUserIds);
159161
}
160162

161163
/** @test */
@@ -273,15 +275,19 @@ public function it_should_get_a_participant_from_userid()
273275
$this->assertInstanceOf(Participant::class, $newParticipant);
274276
}
275277

276-
/**
277-
* @test
278-
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
279-
*/
278+
/** @test */
280279
public function it_should_throw_an_exception_when_participant_is_not_found()
281280
{
282-
$thread = $this->faktory->create('thread');
281+
try {
282+
$thread = $this->faktory->create('thread');
283+
284+
$thread->getParticipantFromUser(99);
285+
} catch (ModelNotFoundException $e) {
286+
$this->assertTrue(true);
287+
return;
288+
}
283289

284-
$thread->getParticipantFromUser(99);
290+
$this->fail('ModelNotFoundException was not called.');
285291
}
286292

287293
/** @test */

0 commit comments

Comments
 (0)