|
6 | 6 | use Cmgmyr\Messenger\Models\Participant;
|
7 | 7 | use Cmgmyr\Messenger\Models\Thread;
|
8 | 8 | use Illuminate\Database\Eloquent\Model as Eloquent;
|
| 9 | +use Illuminate\Database\Eloquent\ModelNotFoundException; |
9 | 10 | use Illuminate\Support\Carbon;
|
10 | 11 | use ReflectionClass;
|
11 | 12 |
|
@@ -126,7 +127,7 @@ public function it_should_get_all_thread_participants()
|
126 | 127 | $this->assertCount(4, $participantIds);
|
127 | 128 | $this->assertEquals(999, end($participantIds));
|
128 | 129 |
|
129 |
| - $this->assertInternalType('array', $participantIds); |
| 130 | + $this->assertIsArray($participantIds); |
130 | 131 | }
|
131 | 132 |
|
132 | 133 | /** @test */
|
@@ -154,8 +155,9 @@ public function it_should_get_all_user_entities_for_a_thread()
|
154 | 155 | $user_2 = $this->faktory->build('participant', ['user_id' => 2]);
|
155 | 156 | $thread->participants()->saveMany([$user_1, $user_2]);
|
156 | 157 |
|
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); |
159 | 161 | }
|
160 | 162 |
|
161 | 163 | /** @test */
|
@@ -273,15 +275,19 @@ public function it_should_get_a_participant_from_userid()
|
273 | 275 | $this->assertInstanceOf(Participant::class, $newParticipant);
|
274 | 276 | }
|
275 | 277 |
|
276 |
| - /** |
277 |
| - * @test |
278 |
| - * @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException |
279 |
| - */ |
| 278 | + /** @test */ |
280 | 279 | public function it_should_throw_an_exception_when_participant_is_not_found()
|
281 | 280 | {
|
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 | + } |
283 | 289 |
|
284 |
| - $thread->getParticipantFromUser(99); |
| 290 | + $this->fail('ModelNotFoundException was not called.'); |
285 | 291 | }
|
286 | 292 |
|
287 | 293 | /** @test */
|
|
0 commit comments