LocationCategoryTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 66
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanDelete() 0 9 1
A testCanCreate() 0 9 1
A testGetCMSFields() 0 5 1
A testCanView() 0 4 1
A testCanEdit() 0 9 1
1
<?php
2
3
namespace Dynamic\Locator\Tests\Model;
4
5
use Dynamic\Locator\Model\LocationCategory;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Security\Member;
9
10
/**
11
 * Class LocationCategoryTest
12
 * @package Dynamic\Locator\Tests\Model
13
 */
14
class LocationCategoryTest extends SapphireTest
15
{
16
    /**
17
     * @var string
18
     */
19
    protected static $fixture_file = 'categoryfixture.yml';
20
21
    /**
22
     *
23
     */
24
    public function testGetCMSFields()
25
    {
26
        $object = $this->objFromFixture(LocationCategory::class, 'service');
27
        $fieldset = $object->getCMSFields();
28
        $this->assertInstanceOf(FieldList::class, $fieldset);
29
    }
30
31
    /**
32
     *
33
     */
34
    public function testCanView()
35
    {
36
        $object = $this->objFromFixture(LocationCategory::class, 'service');
37
        $this->assertTrue($object->canView());
38
    }
39
40
    /**
41
     *
42
     */
43
    public function testCanEdit()
44
    {
45
        $object = $this->objFromFixture(LocationCategory::class, 'service');
46
47
        $admin = $this->objFromFixture(Member::class, 'locationedit');
48
        $this->assertTrue($object->canEdit($admin));
49
50
        $member = $this->objFromFixture(Member::class, 'default');
51
        $this->assertFalse($object->canEdit($member));
52
    }
53
54
    /**
55
     *
56
     */
57
    public function testCanDelete()
58
    {
59
        $object = $this->objFromFixture(LocationCategory::class, 'service');
60
61
        $admin = $this->objFromFixture(Member::class, 'locationdelete');
62
        $this->assertTrue($object->canDelete($admin));
63
64
        $member = $this->objFromFixture(Member::class, 'default');
65
        $this->assertFalse($object->canDelete($member));
66
    }
67
68
    /**
69
     *
70
     */
71
    public function testCanCreate()
72
    {
73
        $object = $this->objFromFixture(LocationCategory::class, 'service');
74
75
        $admin = $this->objFromFixture(Member::class, 'locationcreate');
76
        $this->assertTrue($object->canCreate($admin));
77
78
        $member = $this->objFromFixture(Member::class, 'default');
79
        $this->assertFalse($object->canCreate($member));
80
    }
81
}
82