|
@@ -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'); |
|
@@ -28,7 +28,7 @@ discard block |
|
|
block discarded – undo |
|
28
|
28
|
|
|
29
|
29
|
} |
|
30
|
30
|
|
|
31
|
|
- function testProductDeletion(){ |
|
|
31
|
+ function testProductDeletion() { |
|
32
|
32
|
|
|
33
|
33
|
$this->logInWithPermission('Product_CANCRUD'); |
|
34
|
34
|
$holder = $this->objFromFixture('ProductHolder', 'default'); |
|
@@ -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
|
|
|
@@ -69,7 +69,7 @@ discard block |
|
|
block discarded – undo |
|
69
|
69
|
|
|
70
|
70
|
} |
|
71
|
71
|
|
|
72
|
|
- function testProductTitleTrailingWhiteSpace(){ |
|
|
72
|
+ function testProductTitleTrailingWhiteSpace() { |
|
73
|
73
|
|
|
74
|
74
|
$this->logInWithPermission('ADMIN'); |
|
75
|
75
|
|
|
@@ -84,7 +84,7 @@ discard block |
|
|
block discarded – undo |
|
84
|
84
|
|
|
85
|
85
|
} |
|
86
|
86
|
|
|
87
|
|
- function testProductCategoryCreation(){ |
|
|
87
|
+ function testProductCategoryCreation() { |
|
88
|
88
|
|
|
89
|
89
|
$this->logInWithPermission('Product_CANCRUD'); |
|
90
|
90
|
$category = $this->objFromFixture('ProductCategory', 'apparel'); |
|
@@ -97,7 +97,7 @@ discard block |
|
|
block discarded – undo |
|
97
|
97
|
|
|
98
|
98
|
} |
|
99
|
99
|
|
|
100
|
|
- function testProductCategoryDeletion(){ |
|
|
100
|
+ function testProductCategoryDeletion() { |
|
101
|
101
|
|
|
102
|
102
|
$this->logInWithPermission('Product_CANCRUD'); |
|
103
|
103
|
|
|
@@ -124,11 +124,11 @@ discard block |
|
|
block discarded – undo |
|
124
|
124
|
|
|
125
|
125
|
$category2->delete(); |
|
126
|
126
|
|
|
127
|
|
- $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
|
127
|
+ $this->assertFalse(in_array($category2ID, ProductCategory::get()->column('ID'))); |
|
128
|
128
|
|
|
129
|
129
|
} |
|
130
|
130
|
|
|
131
|
|
- function testOptionGroupCreation(){ |
|
|
131
|
+ function testOptionGroupCreation() { |
|
132
|
132
|
|
|
133
|
133
|
$this->logInWithPermission('Product_CANCRUD'); |
|
134
|
134
|
|
|
@@ -139,7 +139,7 @@ discard block |
|
|
block discarded – undo |
|
139
|
139
|
|
|
140
|
140
|
} |
|
141
|
141
|
|
|
142
|
|
- function testOptionGroupDeletion(){ |
|
|
142
|
+ function testOptionGroupDeletion() { |
|
143
|
143
|
|
|
144
|
144
|
$this->logInWithPermission('ADMIN'); |
|
145
|
145
|
$group = $this->objFromFixture('OptionGroup', 'color'); |
|
@@ -158,7 +158,7 @@ discard block |
|
|
block discarded – undo |
|
158
|
158
|
|
|
159
|
159
|
} |
|
160
|
160
|
|
|
161
|
|
- function testOptionItemCreation(){ |
|
|
161
|
+ function testOptionItemCreation() { |
|
162
|
162
|
|
|
163
|
163
|
$this->logInWithPermission('Product_CANCRUD'); |
|
164
|
164
|
|
|
@@ -176,7 +176,7 @@ discard block |
|
|
block discarded – undo |
|
176
|
176
|
|
|
177
|
177
|
} |
|
178
|
178
|
|
|
179
|
|
- function testOptionItemDeletion(){ |
|
|
179
|
+ function testOptionItemDeletion() { |
|
180
|
180
|
|
|
181
|
181
|
$this->logInWithPermission('ADMIN'); |
|
182
|
182
|
|
|
@@ -200,44 +200,44 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
|
|
201
|
201
|
} |
|
202
|
202
|
|
|
203
|
|
- public function testProductDraftOptionDeletion(){ |
|
|
203
|
+ public function testProductDraftOptionDeletion() { |
|
204
|
204
|
|
|
205
|
|
- self::$use_draft_site = false;//make sure we can publish |
|
|
205
|
+ self::$use_draft_site = false; //make sure we can publish |
|
206
|
206
|
|
|
207
|
207
|
$this->logInWithPermission('ADMIN'); |
|
208
|
208
|
|
|
209
|
|
- $holder = $this->objFromFixture('ProductHolder', 'default');//build holder page, ProductPage can't be on root level |
|
|
209
|
+ $holder = $this->objFromFixture('ProductHolder', 'default'); //build holder page, ProductPage can't be on root level |
|
210
|
210
|
$holder->doPublish(); |
|
211
|
211
|
|
|
212
|
|
- $product = $this->objFromFixture('ProductPage', 'product1');//build product page |
|
|
212
|
+ $product = $this->objFromFixture('ProductPage', 'product1'); //build product page |
|
213
|
213
|
$product->doPublish(); |
|
214
|
214
|
|
|
215
|
215
|
$productID = $product->ID; |
|
216
|
216
|
|
|
217
|
217
|
|
|
218
|
|
- $optionGroup = $this->objFromFixture('OptionGroup', 'size');//build the group for the options |
|
|
218
|
+ $optionGroup = $this->objFromFixture('OptionGroup', 'size'); //build the group for the options |
|
219
|
219
|
$optionGroup->write(); |
|
220
|
|
- $option = $this->objFromFixture('OptionItem', 'small');//build first option |
|
|
220
|
+ $option = $this->objFromFixture('OptionItem', 'small'); //build first option |
|
221
|
221
|
$option->write(); |
|
222
|
|
- $option2 = $this->objFromFixture('OptionItem', 'large');//build second option |
|
|
222
|
+ $option2 = $this->objFromFixture('OptionItem', 'large'); //build second option |
|
223
|
223
|
$option2->write(); |
|
224
|
224
|
|
|
225
|
|
- $this->assertTrue($product->isPublished());//check that product is published |
|
|
225
|
+ $this->assertTrue($product->isPublished()); //check that product is published |
|
226
|
226
|
|
|
227
|
|
- $product->deleteFromStage('Stage');//remove product from draft site |
|
|
227
|
+ $product->deleteFromStage('Stage'); //remove product from draft site |
|
228
|
228
|
|
|
229
|
|
- $this->assertTrue($product->isPublished());//check product is still published |
|
|
229
|
+ $this->assertTrue($product->isPublished()); //check product is still published |
|
230
|
230
|
|
|
231
|
231
|
$testOption = $this->objFromFixture('OptionItem', 'large'); |
|
232
|
232
|
|
|
233
|
|
- $this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0)));//make sure the first option still exists |
|
|
233
|
+ $this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0))); //make sure the first option still exists |
|
234
|
234
|
|
|
235
|
|
- $product->doRestoreToStage();//restore page to draft site |
|
236
|
|
- $product->doUnpublish();//unpublish page |
|
237
|
|
- $product->deleteFromStage('Stage');//remove product from draft site |
|
|
235
|
+ $product->doRestoreToStage(); //restore page to draft site |
|
|
236
|
+ $product->doUnpublish(); //unpublish page |
|
|
237
|
+ $product->deleteFromStage('Stage'); //remove product from draft site |
|
238
|
238
|
|
|
239
|
|
- $checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first();//query same option as above |
|
|
239
|
+ $checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first(); //query same option as above |
|
240
|
240
|
|
|
241
|
|
- $this->assertEquals($checkDeleted->ID, 0);//check that the ID is 0 (empty object/non-existent) |
|
|
241
|
+ $this->assertEquals($checkDeleted->ID, 0); //check that the ID is 0 (empty object/non-existent) |
|
242
|
242
|
} |
|
243
|
243
|
} |
|
244
|
244
|
\ No newline at end of file |