1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class ProductCategoryTest extends SapphireTest |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* @var string |
7
|
|
|
*/ |
8
|
|
|
protected static $fixture_file = 'foxystripe/tests/FoxyStripeTest.yml'; |
9
|
|
|
|
10
|
|
|
public function testGetCMSFields() |
11
|
|
|
{ |
12
|
|
|
$object = $this->objFromFixture('ProductCategory', 'apparel'); |
13
|
|
|
$fields = $object->getCMSFields(); |
14
|
|
|
$this->assertInstanceOf('FieldList', $fields); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
public function testCanView() |
21
|
|
|
{ |
22
|
|
|
$object = $this->objFromFixture('ProductCategory', 'apparel'); |
23
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
24
|
|
|
$this->assertTrue($object->canView($admin)); |
|
|
|
|
25
|
|
|
$member = $this->objFromFixture('Member', 'customer'); |
26
|
|
|
$this->assertTrue($object->canView($member)); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* |
31
|
|
|
*/ |
32
|
|
View Code Duplication |
public function testCanEdit() |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$object = $this->objFromFixture('ProductCategory', 'apparel'); |
35
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
36
|
|
|
$this->assertTrue($object->canEdit($admin)); |
|
|
|
|
37
|
|
|
$member = $this->objFromFixture('Member', 'customer'); |
38
|
|
|
$this->assertFalse($object->canEdit($member)); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* |
43
|
|
|
*/ |
44
|
|
View Code Duplication |
public function testCanDelete() |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$object = $this->objFromFixture('ProductCategory', 'apparel'); |
47
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
48
|
|
|
$this->assertTrue($object->canDelete($admin)); |
|
|
|
|
49
|
|
|
$member = $this->objFromFixture('Member', 'customer'); |
50
|
|
|
$this->assertFalse($object->canDelete($member)); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* |
55
|
|
|
*/ |
56
|
|
View Code Duplication |
public function testCanCreate() |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
$object = $this->objFromFixture('ProductCategory', 'apparel'); |
59
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
60
|
|
|
$this->assertTrue($object->canCreate($admin)); |
|
|
|
|
61
|
|
|
$member = $this->objFromFixture('Member', 'customer'); |
62
|
|
|
$this->assertFalse($object->canCreate($member)); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* |
67
|
|
|
*/ |
68
|
|
|
public function testGetShippingOptions() |
69
|
|
|
{ |
70
|
|
|
$object = singleton('ProductCategory'); |
71
|
|
|
$this->assertTrue(is_array($object->getShippingOptions())); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* |
76
|
|
|
*/ |
77
|
|
|
public function testGetShippingFlatRateTypes() |
78
|
|
|
{ |
79
|
|
|
$object = singleton('ProductCategory'); |
80
|
|
|
$this->assertTrue(is_array($object->getShippingFlatRateTypes())); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* |
85
|
|
|
*/ |
86
|
|
|
public function testGetHandlingFeeTypes() |
87
|
|
|
{ |
88
|
|
|
$object = singleton('ProductCategory'); |
89
|
|
|
$this->assertTrue(is_array($object->getHandlingFeeTypes())); |
|
|
|
|
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* |
94
|
|
|
*/ |
95
|
|
|
public function testGetDiscountTypes() |
96
|
|
|
{ |
97
|
|
|
$object = singleton('ProductCategory'); |
98
|
|
|
$this->assertTrue(is_array($object->getDiscountTypes())); |
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* |
103
|
|
|
*/ |
104
|
|
|
public function testGetDataMap() |
105
|
|
|
{ |
106
|
|
|
$object = singleton('ProductCategory'); |
107
|
|
|
$this->assertTrue(is_array($object->getDataMap())); |
|
|
|
|
108
|
|
|
} |
109
|
|
|
} |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.