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

ManagerPolicyTest::testView()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 17
rs 9.9332
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\ManagerPolicy;
10
11
class ManagerPolicyTest extends BasePolicyTest
12
{
13
    protected function getManagerPolicy() {
14
        return new ManagerPolicy();
15
    }
16
17
    public function testView()
18
    {
19
        //Test 1: applicant can view manager
20
        $ianApplicant = $this->createApplicant();
21
        $maryManager = $this->createManager();
22
        $canApplicantViewManager = $this->getManagerPolicy()->view($ianApplicant->user, $maryManager);
23
        $this->assertTrue($canApplicantViewManager);
24
25
        //Test 2: manager can view self
26
        $canManagerViewSelf = $this->getManagerPolicy()->view($maryManager->user, $maryManager);
27
        $this->assertTrue($canManagerViewSelf);
28
29
        //Test 3: manager can view other manager
30
        $daveManager = $this->createManager();
31
        $sallyManager = $this->createManager();
32
        $canManagerViewManager = $this->getManagerPolicy()->view($daveManager->user, $sallyManager);
33
        $this->assertTrue($canManagerViewManager);
34
    }
35
}
36