Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgmyr committed Sep 16, 2020
2 parents 9cab074 + 67903c0 commit fc9e943
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: cmgmyr
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4

matrix:
include:
- php: 7.1
- php: 7.2
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
allow_failures:
- php: nightly
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
}
],
"require": {
"php": "^7.1.3",
"illuminate/config": "^5.5|^6.0|^7.0",
"illuminate/support": "^5.5|^6.0|^7.0",
"illuminate/database": "^5.5|^6.0|^7.0"
"php": "^7.2",
"illuminate/config": "^5.5|^6.0|^7.0|^8.0",
"illuminate/support": "^5.5|^6.0|^7.0|^8.0",
"illuminate/database": "^5.5|^6.0|^7.0|^8.0"
},
"require-dev": {
"adamwathan/faktory": "0.3.*",
"friendsofphp/php-cs-fixer": "^2.5",
"orchestra/testbench": "^3.0|^4.0|^5.0",
"phpunit/phpunit": "^7.0"
"orchestra/testbench": "^3.0|^4.0|^5.0|^6.0",
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![Latest Version](https://img.shields.io/github/release/cmgmyr/laravel-messenger.svg?style=flat-square)](https://github.com/cmgmyr/laravel-messenger/releases)
[![Total Downloads](https://img.shields.io/packagist/dt/cmgmyr/messenger.svg?style=flat-square)](https://packagist.org/packages/cmgmyr/messenger)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/cmgmyr)

# Laravel Messenger
This package will allow you to add a full user messaging system into your Laravel application.
Expand Down
5 changes: 3 additions & 2 deletions src/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,14 @@ public function getParticipantFromUser($userId)
}

/**
* Restores all participants within a thread that has a new message.
* Restores only trashed participants within a thread that has a new message.
* Others are already active participiants.
*
* @return void
*/
public function activateAllParticipants()
{
$participants = $this->participants()->withTrashed()->get();
$participants = $this->participants()->onlyTrashed()->get();
foreach ($participants as $participant) {
$participant->restore();
}
Expand Down
24 changes: 15 additions & 9 deletions tests/EloquentThreadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cmgmyr\Messenger\Models\Participant;
use Cmgmyr\Messenger\Models\Thread;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Carbon;
use ReflectionClass;

Expand Down Expand Up @@ -126,7 +127,7 @@ public function it_should_get_all_thread_participants()
$this->assertCount(4, $participantIds);
$this->assertEquals(999, end($participantIds));

$this->assertInternalType('array', $participantIds);
$this->assertIsArray($participantIds);
}

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

$threadUserIds = $thread->users()->get()->pluck('id')->toArray();
$this->assertArraySubset([1, 2], $threadUserIds);
$threadUserIds = $thread->users()->get()->pluck('id')->values()->flip();
$this->assertArrayHasKey(1, $threadUserIds);
$this->assertArrayHasKey(2, $threadUserIds);
}

/** @test */
Expand Down Expand Up @@ -273,15 +275,19 @@ public function it_should_get_a_participant_from_userid()
$this->assertInstanceOf(Participant::class, $newParticipant);
}

/**
* @test
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
*/
/** @test */
public function it_should_throw_an_exception_when_participant_is_not_found()
{
$thread = $this->faktory->create('thread');
try {
$thread = $this->faktory->create('thread');

$thread->getParticipantFromUser(99);
} catch (ModelNotFoundException $e) {
$this->assertTrue(true);
return;
}

$thread->getParticipantFromUser(99);
$this->fail('ModelNotFoundException was not called.');
}

/** @test */
Expand Down

0 comments on commit fc9e943

Please sign in to comment.