Completed
Push — master ( f8f77e...d2a4ab )
by Jason
05:01
created

ProductCategoryTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
dl 0
loc 105
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCMSFields() 0 5 1
A testCanEdit() 0 7 1
A testGetDiscountTypes() 0 4 1
A testGetHandlingFeeTypes() 0 4 1
A testCanView() 0 7 1
A testGetShippingFlatRateTypes() 0 4 1
A testGetShippingOptions() 0 4 1
A testGetDataMap() 0 4 1
A testCanDelete() 0 7 1
A testCanCreate() 0 7 1
1
<?php
2
3
namespace Dynamic\FoxyStripe\Test;
4
5
use Dynamic\FoxyStripe\Model\ProductCategory;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Security\Member;
9
10
class ProductCategoryTest extends SapphireTest
11
{
12
    /**
13
     * @var string
14
     */
15
    protected static $fixture_file = 'fixtures.yml';
16
17
    public function testGetCMSFields()
18
    {
19
        $object = $this->objFromFixture(ProductCategory::class, 'apparel');
20
        $fields = $object->getCMSFields();
21
        $this->assertInstanceOf(FieldList::class, $fields);
22
    }
23
24
    /**
25
     *
26
     */
27
    public function testCanView()
28
    {
29
        $object = $this->objFromFixture(ProductCategory::class, 'apparel');
30
        $admin = $this->objFromFixture(Member::class, 'admin');
31
        $this->assertTrue($object->canView($admin));
32
        $member = $this->objFromFixture(Member::class, 'customer');
33
        $this->assertTrue($object->canView($member));
34
    }
35
36
    /**
37
     *
38
     */
39
    public function testCanEdit()
40
    {
41
        $object = $this->objFromFixture(ProductCategory::class, 'apparel');
42
        $admin = $this->objFromFixture(Member::class, 'admin');
43
        $this->assertTrue($object->canEdit($admin));
44
        $member = $this->objFromFixture(Member::class, 'customer');
45
        $this->assertFalse($object->canEdit($member));
46
    }
47
48
    /**
49
     *
50
     */
51
    public function testCanDelete()
52
    {
53
        $object = $this->objFromFixture(ProductCategory::class, 'apparel');
54
        $admin = $this->objFromFixture(Member::class, 'admin');
55
        $this->assertTrue($object->canDelete($admin));
56
        $member = $this->objFromFixture(Member::class, 'customer');
57
        $this->assertFalse($object->canDelete($member));
58
    }
59
60
    /**
61
     *
62
     */
63
    public function testCanCreate()
64
    {
65
        $object = $this->objFromFixture(ProductCategory::class, 'apparel');
66
        $admin = $this->objFromFixture(Member::class, 'admin');
67
        $this->assertTrue($object->canCreate($admin));
68
        $member = $this->objFromFixture(Member::class, 'customer');
69
        $this->assertFalse($object->canCreate($member));
70
    }
71
72
    /**
73
     *
74
     */
75
    public function testGetShippingOptions()
76
    {
77
        $object = singleton(ProductCategory::class);
78
        $this->assertTrue(is_array($object->getShippingOptions()));
79
    }
80
81
    /**
82
     *
83
     */
84
    public function testGetShippingFlatRateTypes()
85
    {
86
        $object = singleton(ProductCategory::class);
87
        $this->assertTrue(is_array($object->getShippingFlatRateTypes()));
88
    }
89
90
    /**
91
     *
92
     */
93
    public function testGetHandlingFeeTypes()
94
    {
95
        $object = singleton(ProductCategory::class);
96
        $this->assertTrue(is_array($object->getHandlingFeeTypes()));
97
    }
98
99
    /**
100
     *
101
     */
102
    public function testGetDiscountTypes()
103
    {
104
        $object = singleton(ProductCategory::class);
105
        $this->assertTrue(is_array($object->getDiscountTypes()));
106
    }
107
108
    /**
109
     *
110
     */
111
    public function testGetDataMap()
112
    {
113
        $object = singleton(ProductCategory::class);
114
        $this->assertTrue(is_array($object->getDataMap()));
115
    }
116
}
117