Passed
Push — enhancement/more-config-option... ( e4871a...997483 )
by Matthew
03:47 queued 42s
created

LocationCategoryTest::testCanCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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