create(); $workspace = Workspace::factory()->create(['user_id' => $user->id]); $workspace->members()->attach($user->id, ['role' => Role::Member->value]); $post = Post::factory()->create(['workspace_id' => $workspace->id]); $channel = new PostChannel; $result = $channel->join($user, $post); expect($result)->toBeTrue(); }); test('post channel denies non-member from joining', function () { $owner = User::factory()->create(); $workspace = Workspace::factory()->create(['user_id' => $owner->id]); $post = Post::factory()->create(['workspace_id' => $workspace->id]); $otherUser = User::factory()->create(); $channel = new PostChannel; $result = $channel->join($otherUser, $post); expect($result)->toBeFalse(); });