Completed
Push — feature/policy_unit_tests ( c4da13...a5ae38 )
by Grant
06:46
created

BasePolicyTest::makeJobPoster()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
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
use App\Models\User;
10
use App\Models\Applicant;
11
use App\Models\Manager;
12
use App\Models\UserRole;
13
use App\Policies\ApplicantPolicy;
14
use App\Policies\ManagerPolicy;
15
16
/**
17
 * A base class for Policy tests
18
 */
19
abstract class BasePolicyTest extends TestCase
20
{
21
22
    protected $nextId = 1;
23
24
    protected function makeId() {
25
        $id = $this->nextId;
26
        $this->nextId = $this->nextId + 1;
27
        return $id;
28
    }
29
30
    protected function makeApplicant() {
31
        //New applicants get a new user
32
        $user =  User::make();
33
        $user->id = $this->makeId();
34
        // Make user an Applicant
35
        $user->user_role()->associate(
36
            UserRole::where('name', 'applicant')->firstOrFail());
37
38
        $userApplicant = new Applicant();
39
        $userApplicant->id = $this->makeId();
40
        $userApplicant->user()->associate($user);
41
42
        return $userApplicant;
43
    }
44
45
    protected function makeManager() {
46
        //New managers get a new user
47
        $user = User::make();
48
        $user->id = $this->makeId();
49
        // Make user a manager
50
        $user->user_role()->associate(
51
            UserRole::where('name', 'manager')->firstOrFail());
52
53
        $userManager = new Manager();
54
        $userManager->id = $this->makeId();
55
        $userManager->user()->associate($user);
56
57
        return $userManager;
58
    }
59
60
    protected function makeJobPoster() {
61
        $jobPoster = JobPoster::make();
0 ignored issues
show
Unused Code introduced by
The assignment to $jobPoster is dead and can be removed.
Loading history...
62
    }
63
64
    //makeManager(), comes with a user
65
66
    //makeJob($manager) {}
67
68
    //makeApplication($applicant, $job) {}
69
}
70