You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace Tests\Base;
use App\Documents\FingerPrintDocument; use App\Documents\UserDocument; use Jenssegers\Mongodb\Eloquent\Model;
trait AuthMethodsTrait { protected function getToken($user = null) { $user = empty($user) ? UserDocument::factory()->create() : $user; $fingerPrint = FingerPrintDocument::factory()->create(['user_id' => $user->id]);
return $fingerPrint->token; }
protected function loginAsAdmin($user = ['id' => 1, 'group_id' => 1, 'name' => 'admin', 'email' => 'admin@gmail.com']) { return $this->loginAs(['*'], $user); }
protected function loginAsUser($permissions = [], $user = ['id' => 1, 'group_id' => 1, 'name' => 'user', 'email' => 'user@gmail.com']) { return $this->loginAs($permissions, $user); }
protected function loginAs($permissions = [], $user = ['id' => 1, 'group_id' => 1, 'name' => 'fake', 'email' => 'fake@gmail.com']) { $user = $user instanceof Model ? $user : new UserDocument($user); $user->permissions = $permissions; $this->be($user);
return $this; } }
|