Skip to content

Commit

Permalink
Merge branch '1.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.travis.yml
#	README.md
#	_config.php
#	code/pages/ProductHolder.php
#	code/pages/ProductPage.php
#	composer.json
#	tests/FoxyStripeTest.yml
#	tests/ProductDiscountTierTest.php
#	tests/ProductPageTest.php
  • Loading branch information
jsirish committed Feb 28, 2017
2 parents 3228c39 + 19915c8 commit 282357f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 19 deletions.
3 changes: 3 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ SiteConfig:
Member:
extensions:
- CustomerExtension
Page:
extensions:
- FoxyStripePageExtension
DateField:
default_config:
showcalendar: true
Expand Down
10 changes: 10 additions & 0 deletions code/extensions/FoxyStripePageExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

class FoxyStripePageExtension extends DataExtension {

// get FoxyCart Store Name for JS call
public function getCartScript() {
return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>';
}

}
3 changes: 0 additions & 3 deletions code/pages/ProductPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ public function getCMSFields()
)), 'Title');
}

// allows CMS fields to be extended
$this->extend('updateCMSFields', $fields);

return $fields;
}

Expand Down
4 changes: 2 additions & 2 deletions docs/en/userguide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Next we will setup your store's DataFeed, which allows FoxyCart to push transact

In CMS > Settings > FoxyStripe

1. Copy `FoxyCart DataFeed URL` to your clipboard - `https://myfoxystripestore.com/foxycart`
1. Copy `FoxyCart DataFeed URL` to your clipboard - `https://myfoxystripestore.com/foxystripe/`

In FoxyCart > Store > Advanced:

Expand All @@ -25,7 +25,7 @@ You can enable this feature by doing the following:

1. In CMS > Settings > FoxyStripe:
* Check 'Enable Single Sign On'
* Copy `Single Sign On URL` to your clipboard - `https://myfoxystripestore.com/foxycart/sso`
* Copy `Single Sign On URL` to your clipboard - `https://myfoxystripestore.com/foxystripe/sso/`
2. In FoxyCart > Store > Advanced:
* Check `enable single sign on`
* Single sign on url - paste the value from FoxyStripe
Expand Down
1 change: 1 addition & 0 deletions templates/Layout/ProductHolder.ss
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@
<% end_if %>
</section>
</div>
$CartScript
81 changes: 67 additions & 14 deletions tests/ProductPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ function setUp(){
$groupForItem->Title = 'Sample-Group';
$groupForItem->write();

$productHolder = ProductHolder::create();
/*$productHolder = ProductHolder::create();
$productHolder->Title = 'Product Holder';
$productHolder->write();
$productHolder->write();*/
}

function testProductCreation(){

$this->logInWithPermission('Product_CANCRUD');
$default = $this->objFromFixture('ProductCategory', 'default');
$default->write();
$holder = $this->objFromFixture('ProductHolder', 'holder');
$holder->doPublish();
$product1 = $this->objFromFixture('ProductPage', 'product1');
$product1->ParentID = ProductHolder::get()->first()->ID;
//$product1->ParentID = ProductHolder::get()->first()->ID;

$product1->doPublish();
$this->assertTrue($product1->isPublished());
Expand All @@ -32,8 +34,9 @@ function testProductCreation(){
function testProductDeletion(){

$this->logInWithPermission('Product_CANCRUD');
$holder = $this->objFromFixture('ProductHolder', 'holder');
$holder->doPublish();
$product2 = $this->objFromFixture('ProductPage', 'product2');
$product2->ParentID = ProductHolder::get()->first()->ID;
$productID = $product2->ID;

$product2->doPublish();
Expand All @@ -57,9 +60,12 @@ function testProductDeletion(){
function testProductTitleLeadingWhiteSpace(){

$this->logInWithPermission('ADMIN');

$holder = $this->objFromFixture('ProductHolder', 'holder');
$holder->doPublish();

$product = $this->objFromFixture('ProductPage', 'product1');
$product->Title = " Test with leading space";
$product->ParentID = ProductHolder::get()->first()->ID;
$product->doPublish();

$this->assertTrue($product->Title == 'Test with leading space');
Expand All @@ -69,9 +75,12 @@ function testProductTitleLeadingWhiteSpace(){
function testProductTitleTrailingWhiteSpace(){

$this->logInWithPermission('ADMIN');

$holder = $this->objFromFixture('ProductHolder', 'holder');
$holder->doPublish();

$product = $this->objFromFixture('ProductPage', 'product1');
$product->Title = "Test with trailing space ";
$product->ParentID = ProductHolder::get()->first()->ID;
$product->doPublish();

$this->assertTrue($product->Title == 'Test with trailing space');
Expand All @@ -94,6 +103,7 @@ function testProductCategoryCreation(){
function testProductCategoryDeletion(){

$this->logInWithPermission('Product_CANCRUD');

$category = $this->objFromFixture('ProductCategory', 'default');
$category->write();

Expand Down Expand Up @@ -124,6 +134,7 @@ function testProductCategoryDeletion(){
function testOptionGroupCreation(){

$this->logInWithPermission('Product_CANCRUD');

$group = $this->objFromFixture('OptionGroup', 'size');
$group->write();

Expand Down Expand Up @@ -153,10 +164,13 @@ function testOptionGroupDeletion(){
function testOptionItemCreation(){

$this->logInWithPermission('Product_CANCRUD');

$optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first();

$option = $this->objFromFixture('OptionItem', 'large');
$option->ProductOptionGroupID = $optionGroup->ID;
$option->write();

$optionID = $option->ID;

$optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first();
Expand All @@ -168,16 +182,13 @@ function testOptionItemCreation(){
function testOptionItemDeletion(){

$this->logInWithPermission('ADMIN');
$optionGroup = (OptionGroup::get()->first())
? OptionGroup::get()->first()
: OptionGroup::create();
if($optionGroup->ID == 0){
$optionGroup->Title = 'Size';
$optionGroup->write();
}

$optionGroup = $this->objFromFixture('OptionGroup', 'size');
$optionGroup->write();

$option = $this->objFromFixture('OptionItem', 'small');
$option->ProductOptionGroupID = $optionGroup->ID;
$option->write();

$optionID = $option->ID;

$this->assertTrue($option->canDelete());
Expand All @@ -192,4 +203,46 @@ function testOptionItemDeletion(){

}

public function testProductDraftOptionDeletion(){

self::$use_draft_site = false;//make sure we can publish

$this->logInWithPermission('ADMIN');

$holder = $this->objFromFixture('ProductHolder', 'holder');//build holder page, ProductPage can't be on root level
$holder->doPublish();

$product = $this->objFromFixture('ProductPage', 'product1');//build product page
$product->doPublish();

$productID = $product->ID;


$optionGroup = $this->objFromFixture('OptionGroup', 'size');//build the group for the options
$optionGroup->write();
$option = $this->objFromFixture('OptionItem', 'small');//build first option
$option->write();
$option2 = $this->objFromFixture('OptionItem', 'large');//build second option
$option2->write();

$this->assertTrue($product->isPublished());//check that product is published

$product->deleteFromStage('Stage');//remove product from draft site

$this->assertTrue($product->isPublished());//check product is still published

$testOption = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first();

$this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0)));//make sure the first option still exists

$product->doRestoreToStage();//restore page to draft site
$product->doUnpublish();//unpublish page
$product->deleteFromStage('Stage');//remove product from draft site

$checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first();//query same option as above

$this->assertEquals($checkDeleted->ID, 0);//check that the ID is 0 (empty object/non-existent)

}

}

0 comments on commit 282357f

Please sign in to comment.