Completed
Push — feature/policy_unit_tests ( 8a95e1...e0fa79 )
by Tristan
07:24
created

BasePolicyTest::makeApplicant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Tests\Unit;
4
5
use Tests\TestCase;
6
use Illuminate\Foundation\Testing\WithFaker;
7
use Illuminate\Foundation\Testing\RefreshDatabase;
8
9
/**
10
 * A base class for Policy tests
11
 */
12
class BasePolicyTest extends TestCase
13
{
14
15
    protected function makeApplicant($id) {
16
        //New applicants get a new user
17
        $user =  User::make();
18
        $user->id = $id;
19
        // Make user an Applicant
20
        $user->user_role()->associate(
21
            UserRole::where('name', 'applicant')->firstOrFail());
22
23
        $userApplicant = new Applicant();
24
        $userApplicant->id = $id;
25
        $userApplicant->user()->associate($user);
26
27
        return $userApplicant;
28
    }
29
}
30