Completed
Pull Request — master (#304)
by Jason
12:34
created
tests/ProductPageTest.php 3 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -2,194 +2,194 @@
 block discarded – undo
2 2
 
3 3
 class ProductPageTest extends FS_Test{
4 4
 
5
-	protected static $use_draft_site = true;
5
+    protected static $use_draft_site = true;
6 6
 
7
-	function setUp(){
8
-		parent::setUp();
7
+    function setUp(){
8
+        parent::setUp();
9 9
 
10
-		$groupForItem = OptionGroup::create();
11
-		$groupForItem->Title = 'Sample-Group';
12
-		$groupForItem->write();
10
+        $groupForItem = OptionGroup::create();
11
+        $groupForItem->Title = 'Sample-Group';
12
+        $groupForItem->write();
13 13
 
14
-		$productHolder = ProductHolder::create();
15
-		$productHolder->Title = 'Product Holder';
16
-		$productHolder->write();
17
-	}
14
+        $productHolder = ProductHolder::create();
15
+        $productHolder->Title = 'Product Holder';
16
+        $productHolder->write();
17
+    }
18 18
 
19
-	function testProductCreation(){
19
+    function testProductCreation(){
20 20
 
21
-		$this->logInWithPermission('Product_CANCRUD');
22
-		$default = $this->objFromFixture('ProductCategory', 'default');
23
-		$default->write();
24
-		$product1 = $this->objFromFixture('ProductPage', 'product1');
25
-		$product1->ParentID = ProductHolder::get()->first()->ID;
21
+        $this->logInWithPermission('Product_CANCRUD');
22
+        $default = $this->objFromFixture('ProductCategory', 'default');
23
+        $default->write();
24
+        $product1 = $this->objFromFixture('ProductPage', 'product1');
25
+        $product1->ParentID = ProductHolder::get()->first()->ID;
26 26
 
27
-		$product1->doPublish();
28
-		$this->assertTrue($product1->isPublished());
27
+        $product1->doPublish();
28
+        $this->assertTrue($product1->isPublished());
29 29
 
30
-	}
30
+    }
31 31
 
32
-	function testProductDeletion(){
32
+    function testProductDeletion(){
33 33
 
34
-		$this->logInWithPermission('Product_CANCRUD');
35
-		$product2 = $this->objFromFixture('ProductPage', 'product2');
36
-		$product2->ParentID = ProductHolder::get()->first()->ID;
37
-		$productID = $product2->ID;
34
+        $this->logInWithPermission('Product_CANCRUD');
35
+        $product2 = $this->objFromFixture('ProductPage', 'product2');
36
+        $product2->ParentID = ProductHolder::get()->first()->ID;
37
+        $productID = $product2->ID;
38 38
 
39
-		$product2->doPublish();
40
-		$this->assertTrue($product2->isPublished());
39
+        $product2->doPublish();
40
+        $this->assertTrue($product2->isPublished());
41 41
 
42
-		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
43
-		$versionsPostPublish = array();
44
-		foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow;
42
+        $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
43
+        $versionsPostPublish = array();
44
+        foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow;
45 45
 
46
-		$product2->delete();
47
-		$this->assertTrue(!$product2->isPublished());
46
+        $product2->delete();
47
+        $this->assertTrue(!$product2->isPublished());
48 48
 
49
-		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
50
-		$versionsPostDelete = array();
51
-		foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow;
49
+        $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
50
+        $versionsPostDelete = array();
51
+        foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow;
52 52
 
53
-		$this->assertTrue($versionsPostPublish == $versionsPostDelete);
53
+        $this->assertTrue($versionsPostPublish == $versionsPostDelete);
54 54
 
55
-	}
55
+    }
56 56
 
57
-	function testProductTitleLeadingWhiteSpace(){
57
+    function testProductTitleLeadingWhiteSpace(){
58 58
 
59
-		$this->logInWithPermission('ADMIN');
60
-		$product = $this->objFromFixture('ProductPage', 'product1');
61
-		$product->Title = " Test with leading space";
62
-		$product->ParentID = ProductHolder::get()->first()->ID;
63
-		$product->doPublish();
59
+        $this->logInWithPermission('ADMIN');
60
+        $product = $this->objFromFixture('ProductPage', 'product1');
61
+        $product->Title = " Test with leading space";
62
+        $product->ParentID = ProductHolder::get()->first()->ID;
63
+        $product->doPublish();
64 64
 
65
-		$this->assertTrue($product->Title == 'Test with leading space');
65
+        $this->assertTrue($product->Title == 'Test with leading space');
66 66
 
67
-	}
67
+    }
68 68
 
69
-	function testProductTitleTrailingWhiteSpace(){
69
+    function testProductTitleTrailingWhiteSpace(){
70 70
 
71
-		$this->logInWithPermission('ADMIN');
72
-		$product = $this->objFromFixture('ProductPage', 'product1');
73
-		$product->Title = "Test with trailing space ";
74
-		$product->ParentID = ProductHolder::get()->first()->ID;
75
-		$product->doPublish();
71
+        $this->logInWithPermission('ADMIN');
72
+        $product = $this->objFromFixture('ProductPage', 'product1');
73
+        $product->Title = "Test with trailing space ";
74
+        $product->ParentID = ProductHolder::get()->first()->ID;
75
+        $product->doPublish();
76 76
 
77
-		$this->assertTrue($product->Title == 'Test with trailing space');
77
+        $this->assertTrue($product->Title == 'Test with trailing space');
78 78
 
79
-	}
79
+    }
80 80
 
81
-	function testProductCategoryCreation(){
81
+    function testProductCategoryCreation(){
82 82
 
83
-		$this->logInWithPermission('Product_CANCRUD');
84
-		$category = $this->objFromFixture('ProductCategory', 'apparel');
85
-		$category->write();
86
-		$categoryID = $category->ID;
83
+        $this->logInWithPermission('Product_CANCRUD');
84
+        $category = $this->objFromFixture('ProductCategory', 'apparel');
85
+        $category->write();
86
+        $categoryID = $category->ID;
87 87
 
88
-		$productCategory = ProductCategory::get()->filter(array('Code'=>'APPAREL'))->first();
88
+        $productCategory = ProductCategory::get()->filter(array('Code'=>'APPAREL'))->first();
89 89
 
90
-		$this->assertTrue($categoryID == $productCategory->ID);
90
+        $this->assertTrue($categoryID == $productCategory->ID);
91 91
 
92
-	}
92
+    }
93 93
 
94
-	function testProductCategoryDeletion(){
94
+    function testProductCategoryDeletion(){
95 95
 
96
-		$this->logInWithPermission('Product_CANCRUD');
97
-		$category = $this->objFromFixture('ProductCategory', 'default');
98
-		$category->write();
96
+        $this->logInWithPermission('Product_CANCRUD');
97
+        $category = $this->objFromFixture('ProductCategory', 'default');
98
+        $category->write();
99 99
 
100
-		$this->assertFalse($category->canDelete());
100
+        $this->assertFalse($category->canDelete());
101 101
 
102
-		$category2 = $this->objFromFixture('ProductCategory', 'apparel');
103
-		$category2->write();
104
-		$category2ID = $category2->ID;
102
+        $category2 = $this->objFromFixture('ProductCategory', 'apparel');
103
+        $category2->write();
104
+        $category2ID = $category2->ID;
105 105
 
106
-		$this->assertTrue($category2->canDelete());
106
+        $this->assertTrue($category2->canDelete());
107 107
 
108
-		$this->logOut();
108
+        $this->logOut();
109 109
 
110
-		$this->logInWithPermission('ADMIN');
110
+        $this->logInWithPermission('ADMIN');
111 111
 
112
-		$this->assertFalse($category->canDelete());
113
-		$this->assertTrue($category2->canDelete());
112
+        $this->assertFalse($category->canDelete());
113
+        $this->assertTrue($category2->canDelete());
114 114
 
115
-		$this->logOut();
116
-		$this->logInWithPermission('Product_CANCRUD');
115
+        $this->logOut();
116
+        $this->logInWithPermission('Product_CANCRUD');
117 117
 
118
-		$category2->delete();
118
+        $category2->delete();
119 119
 
120
-		$this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID')));
120
+        $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID')));
121 121
 
122
-	}
122
+    }
123 123
 
124
-	function testOptionGroupCreation(){
124
+    function testOptionGroupCreation(){
125 125
 
126
-		$this->logInWithPermission('Product_CANCRUD');
127
-		$group = $this->objFromFixture('OptionGroup', 'size');
128
-		$group->write();
126
+        $this->logInWithPermission('Product_CANCRUD');
127
+        $group = $this->objFromFixture('OptionGroup', 'size');
128
+        $group->write();
129 129
 
130
-		$this->assertNotNull(OptionGroup::get()->first());
130
+        $this->assertNotNull(OptionGroup::get()->first());
131 131
 
132
-	}
132
+    }
133 133
 
134
-	function testOptionGroupDeletion(){
134
+    function testOptionGroupDeletion(){
135 135
 
136
-		$this->logInWithPermission('ADMIN');
137
-		$group = $this->objFromFixture('OptionGroup', 'color');
138
-		$group->write();
139
-		$groupID = $group->ID;
136
+        $this->logInWithPermission('ADMIN');
137
+        $group = $this->objFromFixture('OptionGroup', 'color');
138
+        $group->write();
139
+        $groupID = $group->ID;
140 140
 
141
-		$this->assertTrue($group->canDelete());
141
+        $this->assertTrue($group->canDelete());
142 142
 
143
-		$this->logOut();
144
-		$this->logInWithPermission('Product_CANCRUD');
143
+        $this->logOut();
144
+        $this->logInWithPermission('Product_CANCRUD');
145 145
 
146
-		$this->assertTrue($group->canDelete());
147
-		$group->delete();
146
+        $this->assertTrue($group->canDelete());
147
+        $group->delete();
148 148
 
149
-		$this->assertFalse(in_array($groupID, OptionGroup::get()->column('ID')));
149
+        $this->assertFalse(in_array($groupID, OptionGroup::get()->column('ID')));
150 150
 
151
-	}
151
+    }
152 152
 
153
-	function testOptionItemCreation(){
153
+    function testOptionItemCreation(){
154 154
 
155
-		$this->logInWithPermission('Product_CANCRUD');
156
-		$optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first();
157
-		$option = $this->objFromFixture('OptionItem', 'large');
158
-		$option->ProductOptionGroupID = $optionGroup->ID;
159
-		$option->write();
160
-		$optionID = $option->ID;
155
+        $this->logInWithPermission('Product_CANCRUD');
156
+        $optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first();
157
+        $option = $this->objFromFixture('OptionItem', 'large');
158
+        $option->ProductOptionGroupID = $optionGroup->ID;
159
+        $option->write();
160
+        $optionID = $option->ID;
161 161
 
162
-		$optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first();
162
+        $optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first();
163 163
 
164
-		$this->assertEquals($optionID, $optionItem->ID);
164
+        $this->assertEquals($optionID, $optionItem->ID);
165 165
 
166
-	}
166
+    }
167 167
 
168
-	function testOptionItemDeletion(){
168
+    function testOptionItemDeletion(){
169 169
 
170
-		$this->logInWithPermission('ADMIN');
171
-		$optionGroup = (OptionGroup::get()->first())
172
-			? OptionGroup::get()->first()
173
-			: OptionGroup::create();
174
-		if($optionGroup->ID == 0){
175
-			$optionGroup->Title = 'Size';
176
-			$optionGroup->write();
177
-		}
178
-		$option = $this->objFromFixture('OptionItem', 'small');
179
-		$option->ProductOptionGroupID = $optionGroup->ID;
180
-		$option->write();
181
-		$optionID = $option->ID;
170
+        $this->logInWithPermission('ADMIN');
171
+        $optionGroup = (OptionGroup::get()->first())
172
+            ? OptionGroup::get()->first()
173
+            : OptionGroup::create();
174
+        if($optionGroup->ID == 0){
175
+            $optionGroup->Title = 'Size';
176
+            $optionGroup->write();
177
+        }
178
+        $option = $this->objFromFixture('OptionItem', 'small');
179
+        $option->ProductOptionGroupID = $optionGroup->ID;
180
+        $option->write();
181
+        $optionID = $option->ID;
182 182
 
183
-		$this->assertTrue($option->canDelete());
183
+        $this->assertTrue($option->canDelete());
184 184
 
185
-		$this->logOut();
186
-		$this->logInWithPermission('Product_CANCRUD');
185
+        $this->logOut();
186
+        $this->logInWithPermission('Product_CANCRUD');
187 187
 
188
-		$this->assertTrue($option->canDelete());
189
-		$option->delete();
188
+        $this->assertTrue($option->canDelete());
189
+        $option->delete();
190 190
 
191
-		$this->assertFalse(in_array($optionID, OptionItem::get()->column('ID')));
191
+        $this->assertFalse(in_array($optionID, OptionItem::get()->column('ID')));
192 192
 
193
-	}
193
+    }
194 194
 
195 195
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class ProductPageTest extends FS_Test{
3
+class ProductPageTest extends FS_Test {
4 4
 
5 5
 	protected static $use_draft_site = true;
6 6
 
7
-	function setUp(){
7
+	function setUp() {
8 8
 		parent::setUp();
9 9
 
10 10
 		$groupForItem = OptionGroup::create();
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$productHolder->write();
17 17
 	}
18 18
 
19
-	function testProductCreation(){
19
+	function testProductCreation() {
20 20
 
21 21
 		$this->logInWithPermission('Product_CANCRUD');
22 22
 		$default = $this->objFromFixture('ProductCategory', 'default');
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
 	}
31 31
 
32
-	function testProductDeletion(){
32
+	function testProductDeletion() {
33 33
 
34 34
 		$this->logInWithPermission('Product_CANCRUD');
35 35
 		$product2 = $this->objFromFixture('ProductPage', 'product2');
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 		$product2->doPublish();
40 40
 		$this->assertTrue($product2->isPublished());
41 41
 
42
-		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
42
+		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '.$productID);
43 43
 		$versionsPostPublish = array();
44
-		foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow;
44
+		foreach ($versions as $versionRow) $versionsPostPublish[] = $versionRow;
45 45
 
46 46
 		$product2->delete();
47 47
 		$this->assertTrue(!$product2->isPublished());
48 48
 
49
-		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
49
+		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '.$productID);
50 50
 		$versionsPostDelete = array();
51
-		foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow;
51
+		foreach ($versions as $versionRow) $versionsPostDelete[] = $versionRow;
52 52
 
53 53
 		$this->assertTrue($versionsPostPublish == $versionsPostDelete);
54 54
 
55 55
 	}
56 56
 
57
-	function testProductTitleLeadingWhiteSpace(){
57
+	function testProductTitleLeadingWhiteSpace() {
58 58
 
59 59
 		$this->logInWithPermission('ADMIN');
60 60
 		$product = $this->objFromFixture('ProductPage', 'product1');
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 	}
68 68
 
69
-	function testProductTitleTrailingWhiteSpace(){
69
+	function testProductTitleTrailingWhiteSpace() {
70 70
 
71 71
 		$this->logInWithPermission('ADMIN');
72 72
 		$product = $this->objFromFixture('ProductPage', 'product1');
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 	}
80 80
 
81
-	function testProductCategoryCreation(){
81
+	function testProductCategoryCreation() {
82 82
 
83 83
 		$this->logInWithPermission('Product_CANCRUD');
84 84
 		$category = $this->objFromFixture('ProductCategory', 'apparel');
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	}
93 93
 
94
-	function testProductCategoryDeletion(){
94
+	function testProductCategoryDeletion() {
95 95
 
96 96
 		$this->logInWithPermission('Product_CANCRUD');
97 97
 		$category = $this->objFromFixture('ProductCategory', 'default');
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 
118 118
 		$category2->delete();
119 119
 
120
-		$this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID')));
120
+		$this->assertFalse(in_array($category2ID, ProductCategory::get()->column('ID')));
121 121
 
122 122
 	}
123 123
 
124
-	function testOptionGroupCreation(){
124
+	function testOptionGroupCreation() {
125 125
 
126 126
 		$this->logInWithPermission('Product_CANCRUD');
127 127
 		$group = $this->objFromFixture('OptionGroup', 'size');
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 	}
133 133
 
134
-	function testOptionGroupDeletion(){
134
+	function testOptionGroupDeletion() {
135 135
 
136 136
 		$this->logInWithPermission('ADMIN');
137 137
 		$group = $this->objFromFixture('OptionGroup', 'color');
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 	}
152 152
 
153
-	function testOptionItemCreation(){
153
+	function testOptionItemCreation() {
154 154
 
155 155
 		$this->logInWithPermission('Product_CANCRUD');
156 156
 		$optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first();
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
 
166 166
 	}
167 167
 
168
-	function testOptionItemDeletion(){
168
+	function testOptionItemDeletion() {
169 169
 
170 170
 		$this->logInWithPermission('ADMIN');
171 171
 		$optionGroup = (OptionGroup::get()->first())
172 172
 			? OptionGroup::get()->first()
173 173
 			: OptionGroup::create();
174
-		if($optionGroup->ID == 0){
174
+		if ($optionGroup->ID == 0) {
175 175
 			$optionGroup->Title = 'Size';
176 176
 			$optionGroup->write();
177 177
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,14 +41,18 @@
 block discarded – undo
41 41
 
42 42
 		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
43 43
 		$versionsPostPublish = array();
44
-		foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow;
44
+		foreach($versions as $versionRow) {
45
+		    $versionsPostPublish[] = $versionRow;
46
+		}
45 47
 
46 48
 		$product2->delete();
47 49
 		$this->assertTrue(!$product2->isPublished());
48 50
 
49 51
 		$versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID);
50 52
 		$versionsPostDelete = array();
51
-		foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow;
53
+		foreach($versions as $versionRow) {
54
+		    $versionsPostDelete[] = $versionRow;
55
+		}
52 56
 
53 57
 		$this->assertTrue($versionsPostPublish == $versionsPostDelete);
54 58
 
Please login to merge, or discard this patch.
code/pages/ProductHolder.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
      * Products function.
124 124
      * 
125 125
      * @access public
126
-     * @return array
126
+     * @return PaginatedList
127 127
      */
128 128
     public function ProductList($limit = 10)
129 129
     {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
     {
130 130
         $config = SiteConfig::current_site_config();
131 131
 
132
-        if ($config->ProductLimit>0) {
132
+        if ($config->ProductLimit > 0) {
133 133
             $limit = $config->ProductLimit;
134 134
         }
135 135
 
136 136
         if ($config->MultiGroup) {
137 137
             $entries = $this->Products()->sort('SortOrder');
138
-        } else {
139
-            $filter = '"ParentID" = ' . $this->ID;
138
+        }else {
139
+            $filter = '"ParentID" = '.$this->ID;
140 140
 
141 141
             // Build a list of all IDs for ProductGroups that are children
142 142
             $holderIDs = $this->ProductGroupIDs();
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 if ($filter) {
148 148
                     $filter .= ' OR ';
149 149
                 }
150
-                $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ")";
150
+                $filter .= '"ParentID" IN ('.implode(',', $holderIDs).")";
151 151
             }
152 152
 
153 153
             $order = '"SiteTree"."Title" ASC';
Please login to merge, or discard this patch.
code/objects/Order.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@
 block discarded – undo
85 85
 
86 86
     public function getReceiptLink()
87 87
     {
88
-        $obj= HTMLVarchar::create();
89
-        $obj->setValue('<a href="' . $this->ReceiptURL . '" target="_blank" class="cms-panel-link action external-link">view</a>');
88
+        $obj = HTMLVarchar::create();
89
+        $obj->setValue('<a href="'.$this->ReceiptURL.'" target="_blank" class="cms-panel-link action external-link">view</a>');
90 90
         return $obj;
91 91
     }
92 92
 
Please login to merge, or discard this patch.
tests/OptionGroupTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
     {
24 24
         $object = $this->objFromFixture('OptionGroup', 'size');
25 25
         $orig = $object->Title;
26
-        $object->Title = '2' . $orig;
26
+        $object->Title = '2'.$orig;
27 27
         $this->setExpectedException('ValidationException');
28 28
         $object->write();
29 29
 
30
-        $object->Title = $orig . '&';
30
+        $object->Title = $orig.'&';
31 31
         $this->setExpectedException('ValidationException');
32 32
         $object->write();
33 33
     }
Please login to merge, or discard this patch.
code/objects/OptionItem.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -285,7 +285,7 @@
 block discarded – undo
285 285
     }
286 286
 
287 287
     /**
288
-     * @return mixed|string
288
+     * @return string
289 289
      */
290 290
     public function getGeneratedTitle()
291 291
     {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $parentCode = $product->Code;
91 91
 
92 92
         // ProductOptionGroup Dropdown field w/ add new
93
-        $groups = function () {
93
+        $groups = function() {
94 94
             return OptionGroup::get()->map()->toArray();
95 95
         };
96 96
         $groupFields = singleton('OptionGroup')->getCMSFields();
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      * @param bool $returnWithOnlyPlusMinus
225 225
      * @return string
226 226
      */
227
-    public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus=false)
227
+    public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus = false)
228 228
     {
229 229
         switch ($oma) {
230 230
             case 'Subtract':
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     {
292 292
         $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0';
293 293
         $title = $this->Title;
294
-        $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus=true).'$'.$modPrice.')' : '';
294
+        $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus = true).'$'.$modPrice.')' : '';
295 295
         return $title;
296 296
     }
297 297
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      */
301 301
     public function getAvailability()
302 302
     {
303
-        $available = ($this->Available == 1) ? true : false ;
303
+        $available = ($this->Available == 1) ? true : false;
304 304
 
305 305
         $this->extend('updateOptionAvailability', $available);
306 306
 
Please login to merge, or discard this patch.
code/pages/ProductPage.php 1 patch
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             'Image used throughout site to represent this product');
96 96
 
97 97
         // Cateogry Dropdown field w/ add new
98
-        $source = function () {
98
+        $source = function() {
99 99
             return ProductCategory::get()->map()->toArray();
100 100
         };
101 101
         $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source())
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         if (class_exists('GridFieldSortableRows')) {
140 140
             $config->addComponent(new GridFieldSortableRows('SortOrder'));
141 141
             $products = $this->ProductOptions()->sort('SortOrder');
142
-        } else {
142
+        }else {
143 143
             $products = $this->ProductOptions();
144 144
         }
145 145
         $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 ->setFolderName('Uploads/Products')
196 196
                 ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))
197 197
                 ->setAllowedMaxFileNumber(1),
198
-            HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD' . 'Product Image Gallery'), 2),
198
+            HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'.'Product Image Gallery'), 2),
199 199
             $prodImagesField
200 200
                 ->setDescription(_t(
201 201
                     'ProductPage.ProductImagesDescription',
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             $product = ProductPage::get()->byID($this->ID);
242 242
             if (isset($product->ParentID)) {
243 243
                 $origParent = $product->ParentID;
244
-            } else {
244
+            }else {
245 245
                 $origParent = null;
246 246
             }
247 247
             $currentParent = $this->ParentID;
@@ -322,14 +322,13 @@  discard block
 block discarded – undo
322 322
     ) {
323 323
         $optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName;
324 324
         return (SiteConfig::current_site_config()->CartValidation)
325
-            ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) :
326
-            $optionValue;
325
+            ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) : $optionValue;
327 326
     }
328 327
 
329 328
     // get FoxyCart Store Name for JS call
330 329
     public function getCartScript()
331 330
     {
332
-        return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>';
331
+        return '<script src="https://cdn.foxycart.com/'.FoxyCart::getFoxyCartStoreName().'/loader.js" async defer></script>';
333 332
     }
334 333
 
335 334
     /**
Please login to merge, or discard this patch.
code/model/FoxyStripeClient.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 }
128 128
             }
129 129
             if (count($errors)) {
130
-                \SS_Log::log('setCurrentStore errors - ' . json_encode($errors), \SS_Log::WARN);
130
+                \SS_Log::log('setCurrentStore errors - '.json_encode($errors), \SS_Log::WARN);
131 131
             }
132 132
         }
133 133
     }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
         $errors = array_merge($errors, $client->getErrors($result));
144 144
         if (count($errors)) {
145
-            \SS_Log::log('updateStore errors - ' . json_encode($errors), \SS_Log::WARN);
145
+            \SS_Log::log('updateStore errors - '.json_encode($errors), \SS_Log::WARN);
146 146
         }
147 147
     }
148 148
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
         $errors = array_merge($errors, $client->getErrors($result));
171 171
         if (count($errors)) {
172
-            \SS_Log::log('setItemCategoriesURL errors - ' . json_encode($errors), \SS_Log::WARN);
172
+            \SS_Log::log('setItemCategoriesURL errors - '.json_encode($errors), \SS_Log::WARN);
173 173
         }
174 174
     }
175 175
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
         $errors = array_merge($errors, $client->getErrors($result));
196 196
         if (count($errors)) {
197
-            \SS_Log::log('setItemCategories errors - ' . json_encode($errors), \SS_Log::WARN);
197
+            \SS_Log::log('setItemCategories errors - '.json_encode($errors), \SS_Log::WARN);
198 198
         }
199 199
     }
200 200
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                 }
218 218
                 $errors = array_merge($errors, $client->getErrors($result));
219 219
                 if (count($errors)) {
220
-                    \SS_Log::log('getCategory errors - ' . json_encode($errors), \SS_Log::WARN);
220
+                    \SS_Log::log('getCategory errors - '.json_encode($errors), \SS_Log::WARN);
221 221
                 }
222 222
             }
223 223
         }
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 
235 235
         if ($category = $this->getCategory($data['code'])) {
236 236
             $result = $client->patch($category, $data);
237
-        } else {
237
+        }else {
238 238
             $result = $client->post($this->getItemCategoriesURL(), $data);
239 239
         }
240 240
         $errors = array_merge($errors, $client->getErrors($result));
241 241
         if (count($errors)) {
242
-            \SS_Log::log('putCategory errors - ' . json_encode($errors), \SS_Log::WARN);
242
+            \SS_Log::log('putCategory errors - '.json_encode($errors), \SS_Log::WARN);
243 243
         }
244 244
     }
245 245
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
             $errors = array_merge($errors, $client->getErrors($result));
258 258
             if (count($errors)) {
259
-                \SS_Log::log('deleteCategory errors - ' . json_encode($errors), \SS_Log::WARN);
259
+                \SS_Log::log('deleteCategory errors - '.json_encode($errors), \SS_Log::WARN);
260 260
             }
261 261
         }
262 262
     }
Please login to merge, or discard this patch.
code/extensions/FoxyStripeSiteConfig.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Dynamic\FoxyStripe\Model\FoxyStripeClient;
4 4
 
5
-class FoxyStripeSiteConfig extends DataExtension{
5
+class FoxyStripeSiteConfig extends DataExtension {
6 6
 
7 7
 	private static $db = array(
8 8
 	    'StoreTitle' => 'Varchar(255)',
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         'ProductLimit' => 10
28 28
     );
29 29
 
30
-	public function updateCMSFields(FieldList $fields){
30
+	public function updateCMSFields(FieldList $fields) {
31 31
 
32 32
         // set TabSet names to avoid spaces from camel case
33 33
         $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe'));
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         ));
84 84
 
85 85
         // configuration warning
86
-		if(FoxyCart::store_name_warning()!==null){
86
+		if (FoxyCart::store_name_warning() !== null) {
87 87
 			$fields->insertBefore(LiteralField::create(
88 88
                 "StoreSubDomainHeaderWarning",
89 89
                 _t(
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 
175 175
         $siteConfig = SiteConfig::current_site_config();
176 176
 
177
-        if(!$siteConfig->StoreKey) {
177
+        if (!$siteConfig->StoreKey) {
178 178
             $key = FoxyCart::setStoreKey();
179
-            while(!ctype_alnum($key)){
179
+            while (!ctype_alnum($key)) {
180 180
                 $key = FoxyCart::setStoreKey();
181 181
             }
182 182
             $siteConfig->StoreKey = $key;
183 183
             $siteConfig->write();
184
-            DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created');
184
+            DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key ".$key, 'created');
185 185
         }
186 186
     }
187 187
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
                 $errors = array_merge($errors, $client->getErrors($result));
229 229
                 if (count($errors)) {
230
-                    \SS_Log::log('FoxyStripeSiteConfig::onBeforeWrite errors - ' . json_encode($errors), \SS_Log::WARN);
230
+                    \SS_Log::log('FoxyStripeSiteConfig::onBeforeWrite errors - '.json_encode($errors), \SS_Log::WARN);
231 231
                 }
232 232
             }
233 233
         }
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 
5 5
 class FoxyStripeSiteConfig extends DataExtension{
6 6
 
7
-	private static $db = array(
8
-	    'StoreTitle' => 'Varchar(255)',
9
-		'StoreName' => 'Varchar(255)',
7
+    private static $db = array(
8
+        'StoreTitle' => 'Varchar(255)',
9
+        'StoreName' => 'Varchar(255)',
10 10
         'StoreURL' => 'Varchar(255)',
11 11
         'ReceiptURL' => 'Varchar(255)',
12 12
         'StoreEmail' => 'Varchar(255)',
@@ -24,21 +24,21 @@  discard block
 block discarded – undo
24 24
         'UseSingleSignOn' => 'Boolean',
25 25
         'AllowMultiship' => 'Boolean',
26 26
         'StoreTimezone' => 'TimeZone',
27
-		'MultiGroup' => 'Boolean',
28
-		'ProductLimit' => 'Int',
29
-		'MaxQuantity' => 'Int',
27
+        'MultiGroup' => 'Boolean',
28
+        'ProductLimit' => 'Int',
29
+        'MaxQuantity' => 'Int',
30 30
         'client_id' => 'Varchar(255)',
31 31
         'client_secret' => 'Varchar(255)',
32 32
         'access_token' => 'Varchar(255)',
33 33
         'refresh_token' => 'Varchar(255)',
34
-	);
34
+    );
35 35
 
36 36
     // Set Default values
37 37
     private static $defaults = array(
38 38
         'ProductLimit' => 10
39 39
     );
40 40
 
41
-	public function updateCMSFields(FieldList $fields){
41
+    public function updateCMSFields(FieldList $fields){
42 42
 
43 43
         // set TabSet names to avoid spaces from camel case
44 44
         $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe'));
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
         // settings tab
47 47
         $fields->addFieldsToTab('Root.FoxyStripe.Settings', array(
48 48
             // Store Details
49
-			HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3),
50
-			LiteralField::create('DetailsIntro', _t(
51
-				'FoxyStripeSiteConfig.DetailsIntro',
49
+            HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3),
50
+            LiteralField::create('DetailsIntro', _t(
51
+                'FoxyStripeSiteConfig.DetailsIntro',
52 52
                 '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.'
53 53
             )),
54 54
             TextField::create('StoreTitle')
55 55
                 ->setTitle(_t('FoxyStripeSiteConfig.StoreTitle', 'Store Name'))
56 56
                 ->setDescription(_t('FoxyStripeSiteConfig.StoreTitleDescription', 'The name of your store as you\'d like it displayed to your customers')),
57
-			TextField::create('StoreName')
58
-				->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain'))
59
-				->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')),
57
+            TextField::create('StoreName')
58
+                ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain'))
59
+                ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')),
60 60
             TextField::create('StoreURL')
61 61
                 ->setTitle(_t('FoxyStripeSiteConfig.StoreURL', 'Store URL'))
62 62
                 ->setDescription(_t('FoxyStripeSiteConfig.StoreURLDescription', 'The URL of your online store')),
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             CheckboxField::create('AllowMultiship', 'Allow multiple shipments per order')
92 92
 
93 93
 
94
-			// Advanced Settings
94
+            // Advanced Settings
95 95
             /*
96 96
 			HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3),
97 97
 			LiteralField::create('AdvancedIntro', _t(
@@ -115,72 +115,72 @@  discard block
 block discarded – undo
115 115
         ));
116 116
 
117 117
         // configuration warning
118
-		if(FoxyCart::store_name_warning()!==null){
119
-			$fields->insertBefore(LiteralField::create(
118
+        if(FoxyCart::store_name_warning()!==null){
119
+            $fields->insertBefore(LiteralField::create(
120 120
                 "StoreSubDomainHeaderWarning",
121 121
                 _t(
122 122
                     'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning',
123 123
                     "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>"
124 124
                 )
125 125
             ), 'StoreDetails');
126
-		}
126
+        }
127 127
 
128 128
         // products tab
129
-		$fields->addFieldsToTab('Root.FoxyStripe.Products', array(
130
-			HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3),
131
-			CheckboxField::create('MultiGroup')
132
-				->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups'))
133
-				->setDescription(_t(
129
+        $fields->addFieldsToTab('Root.FoxyStripe.Products', array(
130
+            HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3),
131
+            CheckboxField::create('MultiGroup')
132
+                ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups'))
133
+                ->setDescription(_t(
134 134
                     'FoxyStripeSiteConfig.MultiGroupDescription',
135 135
                     'Allows products to be shown in multiple Product Groups'
136 136
                 )),
137
-			HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3),
138
-			NumericField::create('ProductLimit')
139
-				->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page'))
140
-				->setDescription(_t(
137
+            HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3),
138
+            NumericField::create('ProductLimit')
139
+                ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page'))
140
+                ->setDescription(_t(
141 141
                     'FoxyStripeSiteConfig.ProductLimitDescription',
142 142
                     'Number of Products to show per page on a Product Group'
143 143
                 )),
144
-			HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3),
145
-			NumericField::create('MaxQuantity')
146
-				->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity'))
147
-				->setDescription(_t(
144
+            HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3),
145
+            NumericField::create('MaxQuantity')
146
+                ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity'))
147
+                ->setDescription(_t(
148 148
                     'FoxyStripeSiteConfig.MaxQuantityDescription',
149 149
                     'Sets max quantity for product form dropdown (add to cart form - default 10)'
150 150
                 ))
151
-		));
151
+        ));
152 152
 
153 153
         // categories tab
154
-		$fields->addFieldsToTab('Root.FoxyStripe.Categories', array(
155
-			HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3),
156
-			LiteralField::create('CategoryDescrip', _t(
154
+        $fields->addFieldsToTab('Root.FoxyStripe.Categories', array(
155
+            HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3),
156
+            LiteralField::create('CategoryDescrip', _t(
157 157
                 'FoxyStripeSiteConfig.CategoryDescrip',
158 158
                 '<p>FoxyCart Categories offer a way to give products additional behaviors that cannot be accomplished by product options alone, including category specific coupon codes, shipping and handling fees, and email receipts. <a href="https://wiki.foxycart.com/v/2.0/categories" target="_blank">Learn More</a></p><p>Categories you\'ve created in FoxyStripe must also be created in your <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">FoxyCart Categories</a> admin panel.</p>'
159 159
             )),
160
-			GridField::create(
160
+            GridField::create(
161 161
                 'ProductCategory',
162 162
                 _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'),
163 163
                 ProductCategory::get(),
164 164
                 GridFieldConfig_RecordEditor::create()
165 165
             )
166
-		));
166
+        ));
167 167
 
168 168
         // option groups tab
169
-		$fields->addFieldsToTab('Root.FoxyStripe.Groups', array(
170
-			HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3),
171
-			LiteralField::create('OptionGroupsDescrip', _t(
169
+        $fields->addFieldsToTab('Root.FoxyStripe.Groups', array(
170
+            HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3),
171
+            LiteralField::create('OptionGroupsDescrip', _t(
172 172
                 'FoxyStripeSiteConfig.OptionGroupsDescrip',
173 173
                 '<p>Product Option Groups allow you to name a set of product options.</p>'
174 174
             )),
175
-			GridField::create(
175
+            GridField::create(
176 176
                 'OptionGroup',
177 177
                 _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'),
178 178
                 OptionGroup::get(),
179 179
                 GridFieldConfig_RecordEditor::create()
180 180
             )
181
-		));
181
+        ));
182 182
 
183
-		// api tab
183
+        // api tab
184 184
         $fields->addFieldsToTab('Root.FoxyStripe.API', [
185 185
             HeaderField::create('APIHD', 'FoxyCart API Settings', 3),
186 186
             TextField::create('client_id', 'FoxyCart Client ID'),
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             TextField::create('refresh_token', 'FoxyCart Refresh Token'),
190 190
         ]);
191 191
 
192
-	}
192
+    }
193 193
 
194 194
     private static function getSSOLink() {
195 195
         return Director::absoluteBaseURL()."foxystripe/sso/";
Please login to merge, or discard this patch.
tests/FS_Test.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
     protected static $disable_themes = true;
7 7
     protected static $use_draft_site = false;
8 8
 
9
-    public function setUp(){
9
+    public function setUp() {
10 10
         parent::setUp();
11 11
 
12 12
         ini_set('display_errors', 1);
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
         error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
15 15
     }
16 16
 
17
-    public function logOut(){
17
+    public function logOut() {
18 18
         $this->session()->clear('loggedInAs');
19 19
     }
20 20
 
21
-    public function testProductPage(){}
21
+    public function testProductPage() {}
22 22
 
23 23
 }
Please login to merge, or discard this patch.