Completed
Push — feature/manager_localization2 ( de29b5...0f36f8 )
by Xander
16:57 queued 09:59
created

ApplicantPolicyTest::getApplicantPolicy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\Unit\Policies;
4
5
use Tests\TestCase;
6
use Illuminate\Foundation\Testing\WithFaker;
7
use Illuminate\Foundation\Testing\RefreshDatabase;
8
9
use App\Policies\ApplicantPolicy;
10
11
class ApplicantPolicyTest extends BasePolicyTest
12
{
13
    protected function getApplicantPolicy() {
14
        return new ApplicantPolicy();
15
    }
16
17
    public function testView()
18
    {
19
        //Test 1: applicant can view applicant (self)
20
        $bobApplicant = $this->createApplicant();
21
        $userCanViewSelf = $this->getApplicantPolicy()->view($bobApplicant->user, $bobApplicant);
22
        $this->assertTrue($userCanViewSelf);
23
24
        //Test 2: qpplicant cannot view other applicant
25
        $katyApplicant = $this->createApplicant();
26
        $user1CanViewApplicant2 = $this->getApplicantPolicy()->view($katyApplicant->user, $bobApplicant);
27
        $this->assertFalse($user1CanViewApplicant2);
28
29
        //Test 3: manager cannot view applicant
30
        $jillManager = $this->createManager();
31
        $jennyApplicant = $this->createApplicant();
32
        $canManagerViewapplicant = $this->getApplicantPolicy()->view($jillManager->user, $jennyApplicant);
33
        $this->assertFalse($canManagerViewapplicant);
34
35
        //Test 4: applicant starts a job application but doesn't submit.
36
        // Manager should not be able to view applicant
37
38
        //Test 5: applicant submits a job application. Job's manager should be
39
        // able to view applicant.
40
    }
41
42
    public function testCreate() {
43
        //Test 1: applicant cannot create user
44
        $joeApplicant = $this->createApplicant();
45
        $canApplicantCreateUser = $this->getApplicantPolicy()->create($joeApplicant->user);
46
        $this->assertFalse($canApplicantCreateUser);
47
    }
48
}
49
50
// git pull origin this
51
52
// Move these tests to another file? One test per file? Ask G or T.
53
54