@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class CustomerExtension extends DataExtension{ |
|
| 3 | +class CustomerExtension extends DataExtension { |
|
| 4 | 4 | |
| 5 | 5 | private static $db = array( |
| 6 | 6 | 'Customer_ID' => 'Int', |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | $response = FoxyCart::putCustomer($this->owner); |
| 28 | 28 | |
| 29 | 29 | // Grab customer_id record from FoxyCart response, store in Member |
| 30 | - if($response){ |
|
| 30 | + if ($response) { |
|
| 31 | 31 | $foxyResponse = new SimpleXMLElement($response); |
| 32 | - $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 32 | + $this->owner->Customer_ID = (int)$foxyResponse->customer_id; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | $response = FoxyCart::putCustomer($this->owner); |
| 26 | 26 | |
| 27 | 27 | // Grab customer_id record from FoxyCart response, store in Member |
| 28 | - if($response){ |
|
| 29 | - $foxyResponse = new SimpleXMLElement($response); |
|
| 30 | - $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 31 | - } |
|
| 28 | + if($response){ |
|
| 29 | + $foxyResponse = new SimpleXMLElement($response); |
|
| 30 | + $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 31 | + } |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -34,6 +34,9 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $encrypted |
|
| 39 | + */ |
|
| 37 | 40 | public function handleDataFeed($encrypted, $decrypted){ |
| 38 | 41 | //handle encrypted & decrypted data |
| 39 | 42 | $orders = new SimpleXMLElement($decrypted); |
@@ -79,6 +82,10 @@ discard block |
||
| 79 | 82 | } |
| 80 | 83 | } |
| 81 | 84 | |
| 85 | + /** |
|
| 86 | + * @param SimpleXMLElement $orders |
|
| 87 | + * @param DataObject $transaction |
|
| 88 | + */ |
|
| 82 | 89 | public function parseOrderInfo($orders, $transaction) { |
| 83 | 90 | |
| 84 | 91 | foreach ($orders->transactions->transaction as $order) { |
@@ -95,6 +102,10 @@ discard block |
||
| 95 | 102 | } |
| 96 | 103 | } |
| 97 | 104 | |
| 105 | + /** |
|
| 106 | + * @param SimpleXMLElement $orders |
|
| 107 | + * @param DataObject $transaction |
|
| 108 | + */ |
|
| 98 | 109 | public function parseOrderCustomer($orders, $transaction) { |
| 99 | 110 | |
| 100 | 111 | foreach ($orders->transactions->transaction as $order) { |
@@ -133,6 +144,10 @@ discard block |
||
| 133 | 144 | } |
| 134 | 145 | } |
| 135 | 146 | |
| 147 | + /** |
|
| 148 | + * @param SimpleXMLElement $orders |
|
| 149 | + * @param DataObject $transaction |
|
| 150 | + */ |
|
| 136 | 151 | public function parseOrderDetails($orders, $transaction) { |
| 137 | 152 | |
| 138 | 153 | // remove previous OrderDetails so we don't end up with duplicates |
@@ -2,37 +2,37 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FoxyStripe_Controller extends Page_Controller { |
| 4 | 4 | |
| 5 | - const URLSegment = 'foxystripe'; |
|
| 5 | + const URLSegment = 'foxystripe'; |
|
| 6 | 6 | |
| 7 | - public function getURLSegment() { |
|
| 8 | - return self::URLSegment; |
|
| 9 | - } |
|
| 7 | + public function getURLSegment() { |
|
| 8 | + return self::URLSegment; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - static $allowed_actions = array( |
|
| 12 | - 'index', |
|
| 11 | + static $allowed_actions = array( |
|
| 12 | + 'index', |
|
| 13 | 13 | 'sso' |
| 14 | - ); |
|
| 14 | + ); |
|
| 15 | 15 | |
| 16 | - public function index() { |
|
| 17 | - // handle POST from FoxyCart API transaction |
|
| 18 | - if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
|
| 19 | - $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
|
| 16 | + public function index() { |
|
| 17 | + // handle POST from FoxyCart API transaction |
|
| 18 | + if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
|
| 19 | + $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
|
| 20 | 20 | urldecode($_POST["FoxyData"]) : |
| 21 | 21 | urldecode($_POST["FoxySubscriptionData"]); |
| 22 | - $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
| 23 | - self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
|
| 22 | + $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
| 23 | + self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
|
| 24 | 24 | |
| 25 | - // extend to allow for additional integrations with Datafeed |
|
| 26 | - $this->extend('addIntegrations', $FoxyData_encrypted); |
|
| 25 | + // extend to allow for additional integrations with Datafeed |
|
| 26 | + $this->extend('addIntegrations', $FoxyData_encrypted); |
|
| 27 | 27 | |
| 28 | - return 'foxy'; |
|
| 28 | + return 'foxy'; |
|
| 29 | 29 | |
| 30 | - } else { |
|
| 30 | + } else { |
|
| 31 | 31 | |
| 32 | - return "No FoxyData or FoxySubscriptionData received."; |
|
| 32 | + return "No FoxyData or FoxySubscriptionData received."; |
|
| 33 | 33 | |
| 34 | - } |
|
| 35 | - } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function handleDataFeed($encrypted, $decrypted){ |
| 38 | 38 | //handle encrypted & decrypted data |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | |
| 205 | 205 | |
| 206 | - // Single Sign on integration with FoxyCart |
|
| 206 | + // Single Sign on integration with FoxyCart |
|
| 207 | 207 | public function sso() { |
| 208 | 208 | |
| 209 | - // GET variables from FoxyCart Request |
|
| 209 | + // GET variables from FoxyCart Request |
|
| 210 | 210 | $fcsid = $this->request->getVar('fcsid'); |
| 211 | 211 | $timestampNew = strtotime('+30 days'); |
| 212 | 212 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
| 226 | 226 | '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
| 227 | 227 | |
| 228 | - $this->redirect($redirect_complete); |
|
| 228 | + $this->redirect($redirect_complete); |
|
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | |
@@ -17,9 +17,8 @@ discard block |
||
| 17 | 17 | // handle POST from FoxyCart API transaction |
| 18 | 18 | if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
| 19 | 19 | $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
| 20 | - urldecode($_POST["FoxyData"]) : |
|
| 21 | - urldecode($_POST["FoxySubscriptionData"]); |
|
| 22 | - $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
| 20 | + urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]); |
|
| 21 | + $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted); |
|
| 23 | 22 | self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
| 24 | 23 | |
| 25 | 24 | // extend to allow for additional integrations with Datafeed |
@@ -27,14 +26,14 @@ discard block |
||
| 27 | 26 | |
| 28 | 27 | return 'foxy'; |
| 29 | 28 | |
| 30 | - } else { |
|
| 29 | + }else { |
|
| 31 | 30 | |
| 32 | 31 | return "No FoxyData or FoxySubscriptionData received."; |
| 33 | 32 | |
| 34 | 33 | } |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | - public function handleDataFeed($encrypted, $decrypted){ |
|
| 36 | + public function handleDataFeed($encrypted, $decrypted) { |
|
| 38 | 37 | //handle encrypted & decrypted data |
| 39 | 38 | $orders = new SimpleXMLElement($decrypted); |
| 40 | 39 | |
@@ -43,12 +42,11 @@ discard block |
||
| 43 | 42 | |
| 44 | 43 | if (isset($order->id)) { |
| 45 | 44 | ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ? |
| 46 | - $transaction : |
|
| 47 | - $transaction = Order::create(); |
|
| 45 | + $transaction : $transaction = Order::create(); |
|
| 48 | 46 | } |
| 49 | 47 | |
| 50 | 48 | // save base order info |
| 51 | - $transaction->Order_ID = (int) $order->id; |
|
| 49 | + $transaction->Order_ID = (int)$order->id; |
|
| 52 | 50 | $transaction->Response = $decrypted; |
| 53 | 51 | |
| 54 | 52 | // record transaction as order |
@@ -103,11 +101,11 @@ discard block |
||
| 103 | 101 | if (isset($order->customer_email) && $order->is_anonymous == 0) { |
| 104 | 102 | |
| 105 | 103 | // if Customer is existing member, associate with current order |
| 106 | - if(Member::get()->filter('Email', $order->customer_email)->First()) { |
|
| 104 | + if (Member::get()->filter('Email', $order->customer_email)->First()) { |
|
| 107 | 105 | |
| 108 | 106 | $customer = Member::get()->filter('Email', $order->customer_email)->First(); |
| 109 | 107 | |
| 110 | - } else { |
|
| 108 | + }else { |
|
| 111 | 109 | |
| 112 | 110 | // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
| 113 | 111 | Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
@@ -213,17 +211,17 @@ discard block |
||
| 213 | 211 | // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
| 214 | 212 | // fake user will redirect to FC checkout, ask customer to log in |
| 215 | 213 | // to do: consider a login/registration form here if not logged in |
| 216 | - if($Member = Member::currentUser()) { |
|
| 214 | + if ($Member = Member::currentUser()) { |
|
| 217 | 215 | $Member = Member::currentUser(); |
| 218 | - } else { |
|
| 216 | + }else { |
|
| 219 | 217 | $Member = new Member(); |
| 220 | 218 | $Member->Customer_ID = 0; |
| 221 | 219 | } |
| 222 | 220 | |
| 223 | - $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
| 221 | + $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::getStoreKey()); |
|
| 224 | 222 | |
| 225 | - $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
|
| 226 | - '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
|
| 223 | + $redirect_complete = 'https://'.FoxyCart::getFoxyCartStoreName().'.foxycart.com/checkout?fc_auth_token='.$auth_token. |
|
| 224 | + '&fcsid='.$fcsid.'&fc_customer_id='.$Member->Customer_ID.'×tamp='.$timestampNew; |
|
| 227 | 225 | |
| 228 | 226 | $this->redirect($redirect_complete); |
| 229 | 227 | |
@@ -2,13 +2,13 @@ |
||
| 2 | 2 | |
| 3 | 3 | class OrderAdmin extends ModelAdmin { |
| 4 | 4 | |
| 5 | - public static $managed_models = array( |
|
| 6 | - 'Order' |
|
| 7 | - ); |
|
| 5 | + public static $managed_models = array( |
|
| 6 | + 'Order' |
|
| 7 | + ); |
|
| 8 | 8 | |
| 9 | - static $url_segment = 'orders'; |
|
| 9 | + static $url_segment = 'orders'; |
|
| 10 | 10 | |
| 11 | - static $menu_title = 'Orders'; |
|
| 11 | + static $menu_title = 'Orders'; |
|
| 12 | 12 | |
| 13 | 13 | public function getEditForm($id = null, $fields = null) { |
| 14 | 14 | $form = parent::getEditForm($id, $fields); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @package forms |
| 49 | 49 | * @subpackage fields-basic |
| 50 | 50 | */ |
| 51 | -class FoxyStripeDropdownField extends DropdownField{ |
|
| 51 | +class FoxyStripeDropdownField extends DropdownField { |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Mark certain elements as disabled, |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @param array $items Collection of array keys, as defined in the $source array |
| 58 | 58 | */ |
| 59 | - public function setDisabledItems($items){ |
|
| 59 | + public function setDisabledItems($items) { |
|
| 60 | 60 | $controller = Controller::curr(); |
| 61 | 61 | $code = $controller->data()->Code; |
| 62 | 62 | $updated = []; |
| 63 | - if(is_array($items) && !empty($items)){ |
|
| 64 | - foreach($items as $item){ |
|
| 63 | + if (is_array($items) && !empty($items)) { |
|
| 64 | + foreach ($items as $item) { |
|
| 65 | 65 | array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value')); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | $controller = Controller::curr(); |
| 77 | 77 | $code = $controller->data()->Code; |
| 78 | 78 | $updated = []; |
| 79 | - if(is_array($source) && !empty($source)){ |
|
| 80 | - foreach($source as $key => $val){ |
|
| 79 | + if (is_array($source) && !empty($source)) { |
|
| 80 | + foreach ($source as $key => $val) { |
|
| 81 | 81 | $updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -50,41 +50,41 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | class FoxyStripeDropdownField extends DropdownField{ |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Mark certain elements as disabled, |
|
| 55 | - * regardless of the {@link setDisabled()} settings. |
|
| 56 | - * |
|
| 57 | - * @param array $items Collection of array keys, as defined in the $source array |
|
| 53 | + /** |
|
| 54 | + * Mark certain elements as disabled, |
|
| 55 | + * regardless of the {@link setDisabled()} settings. |
|
| 56 | + * |
|
| 57 | + * @param array $items Collection of array keys, as defined in the $source array |
|
| 58 | 58 | * @return $this |
| 59 | - */ |
|
| 60 | - public function setDisabledItems($items){ |
|
| 61 | - $controller = Controller::curr(); |
|
| 62 | - $code = $controller->data()->Code; |
|
| 63 | - $updated = []; |
|
| 64 | - if(is_array($items) && !empty($items)){ |
|
| 65 | - foreach($items as $item){ |
|
| 66 | - array_push($updated, FoxyStripeProduct::getGeneratedValue($code, $this->getName(), $item, 'value')); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - $this->disabledItems = $updated; |
|
| 70 | - return $this; |
|
| 71 | - } |
|
| 59 | + */ |
|
| 60 | + public function setDisabledItems($items){ |
|
| 61 | + $controller = Controller::curr(); |
|
| 62 | + $code = $controller->data()->Code; |
|
| 63 | + $updated = []; |
|
| 64 | + if(is_array($items) && !empty($items)){ |
|
| 65 | + foreach($items as $item){ |
|
| 66 | + array_push($updated, FoxyStripeProduct::getGeneratedValue($code, $this->getName(), $item, 'value')); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + $this->disabledItems = $updated; |
|
| 70 | + return $this; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @param array $source |
|
| 73 | + /** |
|
| 74 | + * @param array $source |
|
| 75 | 75 | * @return $this |
| 76 | - */ |
|
| 77 | - public function setSource($source) { |
|
| 78 | - $controller = Controller::curr(); |
|
| 79 | - $code = $controller->data()->Code; |
|
| 80 | - $updated = []; |
|
| 81 | - if(is_array($source) && !empty($source)){ |
|
| 82 | - foreach($source as $key => $val){ |
|
| 83 | - $updated[FoxyStripeProduct::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val; |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - $this->source = $updated; |
|
| 87 | - return $this; |
|
| 88 | - } |
|
| 76 | + */ |
|
| 77 | + public function setSource($source) { |
|
| 78 | + $controller = Controller::curr(); |
|
| 79 | + $code = $controller->data()->Code; |
|
| 80 | + $updated = []; |
|
| 81 | + if(is_array($source) && !empty($source)){ |
|
| 82 | + foreach($source as $key => $val){ |
|
| 83 | + $updated[FoxyStripeProduct::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + $this->source = $updated; |
|
| 87 | + return $this; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | } |
@@ -2,30 +2,30 @@ |
||
| 2 | 2 | |
| 3 | 3 | class StoreSettingsTest 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 | - $siteConf = SiteConfig::current_site_config(); |
|
| 11 | - $siteConf->StoreName = 'foxystripe'; |
|
| 10 | + $siteConf = SiteConfig::current_site_config(); |
|
| 11 | + $siteConf->StoreName = 'foxystripe'; |
|
| 12 | 12 | $siteConf->requireDefaultRecords(); |
| 13 | - $siteConf->write(); |
|
| 14 | - } |
|
| 13 | + $siteConf->write(); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - function testStoreKey(){ |
|
| 17 | - $pref = FoxyCart::getKeyPrefix(); |
|
| 18 | - $siteConf = SiteConfig::current_site_config(); |
|
| 16 | + function testStoreKey(){ |
|
| 17 | + $pref = FoxyCart::getKeyPrefix(); |
|
| 18 | + $siteConf = SiteConfig::current_site_config(); |
|
| 19 | 19 | |
| 20 | - $this->assertTrue(ctype_alnum($siteConf->StoreKey)); |
|
| 20 | + $this->assertTrue(ctype_alnum($siteConf->StoreKey)); |
|
| 21 | 21 | $this->assertEquals(strlen($siteConf->StoreKey), 60); |
| 22 | 22 | $this->assertEquals(substr($siteConf->StoreKey, 0, 6), $pref); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - function testStoreName(){ |
|
| 26 | - $siteConf = SiteConfig::current_site_config(); |
|
| 25 | + function testStoreName(){ |
|
| 26 | + $siteConf = SiteConfig::current_site_config(); |
|
| 27 | 27 | |
| 28 | 28 | $this->assertEquals($siteConf->StoreName, 'foxystripe'); |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class StoreSettingsTest extends FS_Test{ |
|
| 3 | +class StoreSettingsTest 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 | $siteConf = SiteConfig::current_site_config(); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $siteConf->write(); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - function testStoreKey(){ |
|
| 16 | + function testStoreKey() { |
|
| 17 | 17 | $pref = FoxyCart::getKeyPrefix(); |
| 18 | 18 | $siteConf = SiteConfig::current_site_config(); |
| 19 | 19 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $this->assertEquals(substr($siteConf->StoreKey, 0, 6), $pref); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - function testStoreName(){ |
|
| 25 | + function testStoreName() { |
|
| 26 | 26 | $siteConf = SiteConfig::current_site_config(); |
| 27 | 27 | |
| 28 | 28 | $this->assertEquals($siteConf->StoreName, 'foxystripe'); |
@@ -41,14 +41,18 @@ |
||
| 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 | |
@@ -2,193 +2,193 @@ |
||
| 2 | 2 | |
| 3 | 3 | class ProductPageTest extends FunctionalTest { |
| 4 | 4 | |
| 5 | - protected static $use_draft_site = true; |
|
| 5 | + protected static $use_draft_site = true; |
|
| 6 | 6 | |
| 7 | - function setUp(){ |
|
| 7 | + function setUp(){ |
|
| 8 | 8 | |
| 9 | - $groupForItem = OptionGroup::create(); |
|
| 10 | - $groupForItem->Title = 'Sample-Group'; |
|
| 11 | - $groupForItem->write(); |
|
| 9 | + $groupForItem = OptionGroup::create(); |
|
| 10 | + $groupForItem->Title = 'Sample-Group'; |
|
| 11 | + $groupForItem->write(); |
|
| 12 | 12 | |
| 13 | - $productHolder = ProductHolder::create(); |
|
| 14 | - $productHolder->Title = 'Product Holder'; |
|
| 15 | - $productHolder->write(); |
|
| 16 | - } |
|
| 13 | + $productHolder = ProductHolder::create(); |
|
| 14 | + $productHolder->Title = 'Product Holder'; |
|
| 15 | + $productHolder->write(); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - function testProductCreation(){ |
|
| 18 | + function testProductCreation(){ |
|
| 19 | 19 | |
| 20 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 21 | - $default = $this->objFromFixture('ProductCategory', 'default'); |
|
| 22 | - $default->write(); |
|
| 23 | - $product1 = $this->objFromFixture('ProductPage', 'product1'); |
|
| 24 | - $product1->ParentID = ProductHolder::get()->first()->ID; |
|
| 20 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 21 | + $default = $this->objFromFixture('ProductCategory', 'default'); |
|
| 22 | + $default->write(); |
|
| 23 | + $product1 = $this->objFromFixture('ProductPage', 'product1'); |
|
| 24 | + $product1->ParentID = ProductHolder::get()->first()->ID; |
|
| 25 | 25 | |
| 26 | - $product1->doPublish(); |
|
| 27 | - $this->assertTrue($product1->isPublished()); |
|
| 26 | + $product1->doPublish(); |
|
| 27 | + $this->assertTrue($product1->isPublished()); |
|
| 28 | 28 | |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - function testProductDeletion(){ |
|
| 31 | + function testProductDeletion(){ |
|
| 32 | 32 | |
| 33 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 34 | - $product2 = $this->objFromFixture('ProductPage', 'product2'); |
|
| 35 | - $product2->ParentID = ProductHolder::get()->first()->ID; |
|
| 36 | - $productID = $product2->ID; |
|
| 33 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 34 | + $product2 = $this->objFromFixture('ProductPage', 'product2'); |
|
| 35 | + $product2->ParentID = ProductHolder::get()->first()->ID; |
|
| 36 | + $productID = $product2->ID; |
|
| 37 | 37 | |
| 38 | - $product2->doPublish(); |
|
| 39 | - $this->assertTrue($product2->isPublished()); |
|
| 38 | + $product2->doPublish(); |
|
| 39 | + $this->assertTrue($product2->isPublished()); |
|
| 40 | 40 | |
| 41 | - $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 42 | - $versionsPostPublish = array(); |
|
| 43 | - foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 41 | + $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 42 | + $versionsPostPublish = array(); |
|
| 43 | + foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 44 | 44 | |
| 45 | - $product2->delete(); |
|
| 46 | - $this->assertTrue(!$product2->isPublished()); |
|
| 45 | + $product2->delete(); |
|
| 46 | + $this->assertTrue(!$product2->isPublished()); |
|
| 47 | 47 | |
| 48 | - $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 49 | - $versionsPostDelete = array(); |
|
| 50 | - foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 48 | + $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 49 | + $versionsPostDelete = array(); |
|
| 50 | + foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 51 | 51 | |
| 52 | - $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
|
| 52 | + $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
|
| 53 | 53 | |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - function testProductTitleLeadingWhiteSpace(){ |
|
| 56 | + function testProductTitleLeadingWhiteSpace(){ |
|
| 57 | 57 | |
| 58 | - $this->logInWithPermission('ADMIN'); |
|
| 59 | - $product = $this->objFromFixture('ProductPage', 'product1'); |
|
| 60 | - $product->Title = " Test with leading space"; |
|
| 61 | - $product->ParentID = ProductHolder::get()->first()->ID; |
|
| 62 | - $product->doPublish(); |
|
| 58 | + $this->logInWithPermission('ADMIN'); |
|
| 59 | + $product = $this->objFromFixture('ProductPage', 'product1'); |
|
| 60 | + $product->Title = " Test with leading space"; |
|
| 61 | + $product->ParentID = ProductHolder::get()->first()->ID; |
|
| 62 | + $product->doPublish(); |
|
| 63 | 63 | |
| 64 | - $this->assertTrue($product->Title == 'Test with leading space'); |
|
| 64 | + $this->assertTrue($product->Title == 'Test with leading space'); |
|
| 65 | 65 | |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - function testProductTitleTrailingWhiteSpace(){ |
|
| 68 | + function testProductTitleTrailingWhiteSpace(){ |
|
| 69 | 69 | |
| 70 | - $this->logInWithPermission('ADMIN'); |
|
| 71 | - $product = $this->objFromFixture('ProductPage', 'product1'); |
|
| 72 | - $product->Title = "Test with trailing space "; |
|
| 73 | - $product->ParentID = ProductHolder::get()->first()->ID; |
|
| 74 | - $product->doPublish(); |
|
| 70 | + $this->logInWithPermission('ADMIN'); |
|
| 71 | + $product = $this->objFromFixture('ProductPage', 'product1'); |
|
| 72 | + $product->Title = "Test with trailing space "; |
|
| 73 | + $product->ParentID = ProductHolder::get()->first()->ID; |
|
| 74 | + $product->doPublish(); |
|
| 75 | 75 | |
| 76 | - $this->assertTrue($product->Title == 'Test with trailing space'); |
|
| 76 | + $this->assertTrue($product->Title == 'Test with trailing space'); |
|
| 77 | 77 | |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - function testProductCategoryCreation(){ |
|
| 80 | + function testProductCategoryCreation(){ |
|
| 81 | 81 | |
| 82 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 83 | - $category = $this->objFromFixture('ProductCategory', 'apparel'); |
|
| 84 | - $category->write(); |
|
| 85 | - $categoryID = $category->ID; |
|
| 82 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 83 | + $category = $this->objFromFixture('ProductCategory', 'apparel'); |
|
| 84 | + $category->write(); |
|
| 85 | + $categoryID = $category->ID; |
|
| 86 | 86 | |
| 87 | - $productCategory = ProductCategory::get()->filter(array('Code'=>'APPAREL'))->first(); |
|
| 87 | + $productCategory = ProductCategory::get()->filter(array('Code'=>'APPAREL'))->first(); |
|
| 88 | 88 | |
| 89 | - $this->assertTrue($categoryID == $productCategory->ID); |
|
| 89 | + $this->assertTrue($categoryID == $productCategory->ID); |
|
| 90 | 90 | |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - function testProductCategoryDeletion(){ |
|
| 93 | + function testProductCategoryDeletion(){ |
|
| 94 | 94 | |
| 95 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 96 | - $category = $this->objFromFixture('ProductCategory', 'default'); |
|
| 97 | - $category->write(); |
|
| 95 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 96 | + $category = $this->objFromFixture('ProductCategory', 'default'); |
|
| 97 | + $category->write(); |
|
| 98 | 98 | |
| 99 | - $this->assertFalse($category->canDelete()); |
|
| 99 | + $this->assertFalse($category->canDelete()); |
|
| 100 | 100 | |
| 101 | - $category2 = $this->objFromFixture('ProductCategory', 'apparel'); |
|
| 102 | - $category2->write(); |
|
| 103 | - $category2ID = $category2->ID; |
|
| 101 | + $category2 = $this->objFromFixture('ProductCategory', 'apparel'); |
|
| 102 | + $category2->write(); |
|
| 103 | + $category2ID = $category2->ID; |
|
| 104 | 104 | |
| 105 | - $this->assertTrue($category2->canDelete()); |
|
| 105 | + $this->assertTrue($category2->canDelete()); |
|
| 106 | 106 | |
| 107 | - $this->logOut(); |
|
| 107 | + $this->logOut(); |
|
| 108 | 108 | |
| 109 | - $this->logInWithPermission('ADMIN'); |
|
| 109 | + $this->logInWithPermission('ADMIN'); |
|
| 110 | 110 | |
| 111 | - $this->assertFalse($category->canDelete()); |
|
| 112 | - $this->assertTrue($category2->canDelete()); |
|
| 111 | + $this->assertFalse($category->canDelete()); |
|
| 112 | + $this->assertTrue($category2->canDelete()); |
|
| 113 | 113 | |
| 114 | - $this->logOut(); |
|
| 115 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 114 | + $this->logOut(); |
|
| 115 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 116 | 116 | |
| 117 | - $category2->delete(); |
|
| 117 | + $category2->delete(); |
|
| 118 | 118 | |
| 119 | - $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
| 119 | + $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
| 120 | 120 | |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - function testOptionGroupCreation(){ |
|
| 123 | + function testOptionGroupCreation(){ |
|
| 124 | 124 | |
| 125 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 126 | - $group = $this->objFromFixture('OptionGroup', 'size'); |
|
| 127 | - $group->write(); |
|
| 125 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 126 | + $group = $this->objFromFixture('OptionGroup', 'size'); |
|
| 127 | + $group->write(); |
|
| 128 | 128 | |
| 129 | - $this->assertNotNull(OptionGroup::get()->first()); |
|
| 129 | + $this->assertNotNull(OptionGroup::get()->first()); |
|
| 130 | 130 | |
| 131 | - } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - function testOptionGroupDeletion(){ |
|
| 133 | + function testOptionGroupDeletion(){ |
|
| 134 | 134 | |
| 135 | - $this->logInWithPermission('ADMIN'); |
|
| 136 | - $group = $this->objFromFixture('OptionGroup', 'color'); |
|
| 137 | - $group->write(); |
|
| 138 | - $groupID = $group->ID; |
|
| 135 | + $this->logInWithPermission('ADMIN'); |
|
| 136 | + $group = $this->objFromFixture('OptionGroup', 'color'); |
|
| 137 | + $group->write(); |
|
| 138 | + $groupID = $group->ID; |
|
| 139 | 139 | |
| 140 | - $this->assertTrue($group->canDelete()); |
|
| 140 | + $this->assertTrue($group->canDelete()); |
|
| 141 | 141 | |
| 142 | - $this->logOut(); |
|
| 143 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 142 | + $this->logOut(); |
|
| 143 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 144 | 144 | |
| 145 | - $this->assertTrue($group->canDelete()); |
|
| 146 | - $group->delete(); |
|
| 145 | + $this->assertTrue($group->canDelete()); |
|
| 146 | + $group->delete(); |
|
| 147 | 147 | |
| 148 | - $this->assertFalse(in_array($groupID, OptionGroup::get()->column('ID'))); |
|
| 148 | + $this->assertFalse(in_array($groupID, OptionGroup::get()->column('ID'))); |
|
| 149 | 149 | |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - function testOptionItemCreation(){ |
|
| 152 | + function testOptionItemCreation(){ |
|
| 153 | 153 | |
| 154 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 155 | - $optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first(); |
|
| 156 | - $option = $this->objFromFixture('OptionItem', 'large'); |
|
| 157 | - $option->ProductOptionGroupID = $optionGroup->ID; |
|
| 158 | - $option->write(); |
|
| 159 | - $optionID = $option->ID; |
|
| 154 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 155 | + $optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first(); |
|
| 156 | + $option = $this->objFromFixture('OptionItem', 'large'); |
|
| 157 | + $option->ProductOptionGroupID = $optionGroup->ID; |
|
| 158 | + $option->write(); |
|
| 159 | + $optionID = $option->ID; |
|
| 160 | 160 | |
| 161 | - $optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first(); |
|
| 161 | + $optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first(); |
|
| 162 | 162 | |
| 163 | - $this->assertEquals($optionID, $optionItem->ID); |
|
| 163 | + $this->assertEquals($optionID, $optionItem->ID); |
|
| 164 | 164 | |
| 165 | - } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - function testOptionItemDeletion(){ |
|
| 167 | + function testOptionItemDeletion(){ |
|
| 168 | 168 | |
| 169 | - $this->logInWithPermission('ADMIN'); |
|
| 170 | - $optionGroup = (OptionGroup::get()->first()) |
|
| 171 | - ? OptionGroup::get()->first() |
|
| 172 | - : OptionGroup::create(); |
|
| 173 | - if($optionGroup->ID == 0){ |
|
| 174 | - $optionGroup->Title = 'Size'; |
|
| 175 | - $optionGroup->write(); |
|
| 176 | - } |
|
| 177 | - $option = $this->objFromFixture('OptionItem', 'small'); |
|
| 178 | - $option->ProductOptionGroupID = $optionGroup->ID; |
|
| 179 | - $option->write(); |
|
| 180 | - $optionID = $option->ID; |
|
| 169 | + $this->logInWithPermission('ADMIN'); |
|
| 170 | + $optionGroup = (OptionGroup::get()->first()) |
|
| 171 | + ? OptionGroup::get()->first() |
|
| 172 | + : OptionGroup::create(); |
|
| 173 | + if($optionGroup->ID == 0){ |
|
| 174 | + $optionGroup->Title = 'Size'; |
|
| 175 | + $optionGroup->write(); |
|
| 176 | + } |
|
| 177 | + $option = $this->objFromFixture('OptionItem', 'small'); |
|
| 178 | + $option->ProductOptionGroupID = $optionGroup->ID; |
|
| 179 | + $option->write(); |
|
| 180 | + $optionID = $option->ID; |
|
| 181 | 181 | |
| 182 | - $this->assertTrue($option->canDelete()); |
|
| 182 | + $this->assertTrue($option->canDelete()); |
|
| 183 | 183 | |
| 184 | - $this->logOut(); |
|
| 185 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 184 | + $this->logOut(); |
|
| 185 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 186 | 186 | |
| 187 | - $this->assertTrue($option->canDelete()); |
|
| 188 | - $option->delete(); |
|
| 187 | + $this->assertTrue($option->canDelete()); |
|
| 188 | + $option->delete(); |
|
| 189 | 189 | |
| 190 | - $this->assertFalse(in_array($optionID, OptionItem::get()->column('ID'))); |
|
| 190 | + $this->assertFalse(in_array($optionID, OptionItem::get()->column('ID'))); |
|
| 191 | 191 | |
| 192 | - } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | protected static $use_draft_site = true; |
| 6 | 6 | |
| 7 | - function setUp(){ |
|
| 7 | + function setUp() { |
|
| 8 | 8 | |
| 9 | 9 | $groupForItem = OptionGroup::create(); |
| 10 | 10 | $groupForItem->Title = 'Sample-Group'; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $productHolder->write(); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - function testProductCreation(){ |
|
| 18 | + function testProductCreation() { |
|
| 19 | 19 | |
| 20 | 20 | $this->logInWithPermission('Product_CANCRUD'); |
| 21 | 21 | $default = $this->objFromFixture('ProductCategory', 'default'); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - function testProductDeletion(){ |
|
| 31 | + function testProductDeletion() { |
|
| 32 | 32 | |
| 33 | 33 | $this->logInWithPermission('Product_CANCRUD'); |
| 34 | 34 | $product2 = $this->objFromFixture('ProductPage', 'product2'); |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | $product2->doPublish(); |
| 39 | 39 | $this->assertTrue($product2->isPublished()); |
| 40 | 40 | |
| 41 | - $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 41 | + $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '.$productID); |
|
| 42 | 42 | $versionsPostPublish = array(); |
| 43 | - foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 43 | + foreach ($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 44 | 44 | |
| 45 | 45 | $product2->delete(); |
| 46 | 46 | $this->assertTrue(!$product2->isPublished()); |
| 47 | 47 | |
| 48 | - $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 48 | + $versions = DB::query('Select * FROM "ProductPage_versions" WHERE "RecordID" = '.$productID); |
|
| 49 | 49 | $versionsPostDelete = array(); |
| 50 | - foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 50 | + foreach ($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 51 | 51 | |
| 52 | 52 | $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - function testProductTitleLeadingWhiteSpace(){ |
|
| 56 | + function testProductTitleLeadingWhiteSpace() { |
|
| 57 | 57 | |
| 58 | 58 | $this->logInWithPermission('ADMIN'); |
| 59 | 59 | $product = $this->objFromFixture('ProductPage', 'product1'); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - function testProductTitleTrailingWhiteSpace(){ |
|
| 68 | + function testProductTitleTrailingWhiteSpace() { |
|
| 69 | 69 | |
| 70 | 70 | $this->logInWithPermission('ADMIN'); |
| 71 | 71 | $product = $this->objFromFixture('ProductPage', 'product1'); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - function testProductCategoryCreation(){ |
|
| 80 | + function testProductCategoryCreation() { |
|
| 81 | 81 | |
| 82 | 82 | $this->logInWithPermission('Product_CANCRUD'); |
| 83 | 83 | $category = $this->objFromFixture('ProductCategory', 'apparel'); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - function testProductCategoryDeletion(){ |
|
| 93 | + function testProductCategoryDeletion() { |
|
| 94 | 94 | |
| 95 | 95 | $this->logInWithPermission('Product_CANCRUD'); |
| 96 | 96 | $category = $this->objFromFixture('ProductCategory', 'default'); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $category2->delete(); |
| 118 | 118 | |
| 119 | - $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
| 119 | + $this->assertFalse(in_array($category2ID, ProductCategory::get()->column('ID'))); |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - function testOptionGroupCreation(){ |
|
| 123 | + function testOptionGroupCreation() { |
|
| 124 | 124 | |
| 125 | 125 | $this->logInWithPermission('Product_CANCRUD'); |
| 126 | 126 | $group = $this->objFromFixture('OptionGroup', 'size'); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - function testOptionGroupDeletion(){ |
|
| 133 | + function testOptionGroupDeletion() { |
|
| 134 | 134 | |
| 135 | 135 | $this->logInWithPermission('ADMIN'); |
| 136 | 136 | $group = $this->objFromFixture('OptionGroup', 'color'); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - function testOptionItemCreation(){ |
|
| 152 | + function testOptionItemCreation() { |
|
| 153 | 153 | |
| 154 | 154 | $this->logInWithPermission('Product_CANCRUD'); |
| 155 | 155 | $optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first(); |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - function testOptionItemDeletion(){ |
|
| 167 | + function testOptionItemDeletion() { |
|
| 168 | 168 | |
| 169 | 169 | $this->logInWithPermission('ADMIN'); |
| 170 | 170 | $optionGroup = (OptionGroup::get()->first()) |
| 171 | 171 | ? OptionGroup::get()->first() |
| 172 | 172 | : OptionGroup::create(); |
| 173 | - if($optionGroup->ID == 0){ |
|
| 173 | + if ($optionGroup->ID == 0) { |
|
| 174 | 174 | $optionGroup->Title = 'Size'; |
| 175 | 175 | $optionGroup->write(); |
| 176 | 176 | } |
@@ -2,79 +2,79 @@ |
||
| 2 | 2 | |
| 3 | 3 | class ProductDiscountTierTest 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 | - $productHolder = ProductHolder::create(); |
|
| 11 | - $productHolder->Title = 'Product Holder'; |
|
| 12 | - $productHolder->write(); |
|
| 10 | + $productHolder = ProductHolder::create(); |
|
| 11 | + $productHolder->Title = 'Product Holder'; |
|
| 12 | + $productHolder->write(); |
|
| 13 | 13 | |
| 14 | - $product = $this->objFromFixture('ProductPage', 'product1'); |
|
| 15 | - $product->ParentID = $productHolder->ID; |
|
| 16 | - $product->write(); |
|
| 17 | - } |
|
| 14 | + $product = $this->objFromFixture('ProductPage', 'product1'); |
|
| 15 | + $product->ParentID = $productHolder->ID; |
|
| 16 | + $product->write(); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function testProductDiscountTierCreation(){ |
|
| 20 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 19 | + public function testProductDiscountTierCreation(){ |
|
| 20 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 21 | 21 | |
| 22 | - $discount = ProductPage::get()->first(); |
|
| 22 | + $discount = ProductPage::get()->first(); |
|
| 23 | 23 | |
| 24 | - $tier = $this->objFromFixture('ProductDiscountTier', 'fiveforten'); |
|
| 25 | - $tier->ProductPageID = $discount->ID; |
|
| 26 | - $tier->write(); |
|
| 27 | - $tierID = $tier->ID; |
|
| 24 | + $tier = $this->objFromFixture('ProductDiscountTier', 'fiveforten'); |
|
| 25 | + $tier->ProductPageID = $discount->ID; |
|
| 26 | + $tier->write(); |
|
| 27 | + $tierID = $tier->ID; |
|
| 28 | 28 | |
| 29 | - $checkTier = ProductDiscountTier::get()->byID($tierID); |
|
| 29 | + $checkTier = ProductDiscountTier::get()->byID($tierID); |
|
| 30 | 30 | |
| 31 | - $this->assertEquals($checkTier->Quantity, 5); |
|
| 32 | - $this->assertEquals($checkTier->Percentage, 10); |
|
| 31 | + $this->assertEquals($checkTier->Quantity, 5); |
|
| 32 | + $this->assertEquals($checkTier->Percentage, 10); |
|
| 33 | 33 | |
| 34 | - $this->logOut(); |
|
| 35 | - } |
|
| 34 | + $this->logOut(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function testProductDiscountTierEdit(){ |
|
| 38 | - $this->logInWithPermission('ADMIN'); |
|
| 37 | + public function testProductDiscountTierEdit(){ |
|
| 38 | + $this->logInWithPermission('ADMIN'); |
|
| 39 | 39 | |
| 40 | - $discount = ProductPage::get()->first(); |
|
| 40 | + $discount = ProductPage::get()->first(); |
|
| 41 | 41 | |
| 42 | - $tier = $this->objFromFixture('ProductDiscountTier', 'fiveforten'); |
|
| 43 | - $tier->ProductPageID = $discount->ID; |
|
| 44 | - $tier->write(); |
|
| 45 | - $tierID = $tier->ID; |
|
| 46 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 42 | + $tier = $this->objFromFixture('ProductDiscountTier', 'fiveforten'); |
|
| 43 | + $tier->ProductPageID = $discount->ID; |
|
| 44 | + $tier->write(); |
|
| 45 | + $tierID = $tier->ID; |
|
| 46 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 47 | 47 | |
| 48 | - $tier->Quantity = 2; |
|
| 49 | - $tier->Percentage = 5; |
|
| 50 | - $tier->write(); |
|
| 48 | + $tier->Quantity = 2; |
|
| 49 | + $tier->Percentage = 5; |
|
| 50 | + $tier->write(); |
|
| 51 | 51 | |
| 52 | - $checkTier = ProductDiscountTier::get()->byID($tierID); |
|
| 52 | + $checkTier = ProductDiscountTier::get()->byID($tierID); |
|
| 53 | 53 | |
| 54 | - $this->assertEquals($checkTier->Quantity, 2); |
|
| 55 | - $this->assertEquals($checkTier->Percentage, 5); |
|
| 54 | + $this->assertEquals($checkTier->Quantity, 2); |
|
| 55 | + $this->assertEquals($checkTier->Percentage, 5); |
|
| 56 | 56 | |
| 57 | - $this->logOut(); |
|
| 58 | - } |
|
| 57 | + $this->logOut(); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - public function testProductDiscountTierDeletion(){ |
|
| 61 | - $this->logInWithPermission('ADMIN'); |
|
| 60 | + public function testProductDiscountTierDeletion(){ |
|
| 61 | + $this->logInWithPermission('ADMIN'); |
|
| 62 | 62 | |
| 63 | - $discount = ProductPage::get()->first(); |
|
| 63 | + $discount = ProductPage::get()->first(); |
|
| 64 | 64 | |
| 65 | - $tier = $this->objFromFixture('ProductDiscountTier', 'fiveforten'); |
|
| 66 | - $tier->ProductPageID = $discount->ID; |
|
| 67 | - $tier->write(); |
|
| 68 | - $tierID = $tier->ID; |
|
| 65 | + $tier = $this->objFromFixture('ProductDiscountTier', 'fiveforten'); |
|
| 66 | + $tier->ProductPageID = $discount->ID; |
|
| 67 | + $tier->write(); |
|
| 68 | + $tierID = $tier->ID; |
|
| 69 | 69 | |
| 70 | - $this->logOut(); |
|
| 70 | + $this->logOut(); |
|
| 71 | 71 | |
| 72 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 72 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 73 | 73 | |
| 74 | - $tier->delete(); |
|
| 75 | - $this->assertTrue(!ProductDiscountTier::get()->byID($tierID)); |
|
| 74 | + $tier->delete(); |
|
| 75 | + $this->assertTrue(!ProductDiscountTier::get()->byID($tierID)); |
|
| 76 | 76 | |
| 77 | - $this->logOut(); |
|
| 78 | - } |
|
| 77 | + $this->logOut(); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class ProductDiscountTierTest extends FS_Test{ |
|
| 3 | +class ProductDiscountTierTest 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 | $productHolder = ProductHolder::create(); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $product->write(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function testProductDiscountTierCreation(){ |
|
| 19 | + public function testProductDiscountTierCreation() { |
|
| 20 | 20 | $this->logInWithPermission('Product_CANCRUD'); |
| 21 | 21 | |
| 22 | 22 | $discount = ProductPage::get()->first(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $this->logOut(); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function testProductDiscountTierEdit(){ |
|
| 37 | + public function testProductDiscountTierEdit() { |
|
| 38 | 38 | $this->logInWithPermission('ADMIN'); |
| 39 | 39 | |
| 40 | 40 | $discount = ProductPage::get()->first(); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->logOut(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function testProductDiscountTierDeletion(){ |
|
| 60 | + public function testProductDiscountTierDeletion() { |
|
| 61 | 61 | $this->logInWithPermission('ADMIN'); |
| 62 | 62 | |
| 63 | 63 | $discount = ProductPage::get()->first(); |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class FS_Test extends FunctionalTest{ |
|
| 3 | +class FS_Test extends FunctionalTest { |
|
| 4 | 4 | |
| 5 | 5 | protected static $fixture_file = 'foxystripe/tests/FoxyStripeTest.yml'; |
| 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 |
||
| 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 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | private $product; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * @param $siteConfig |
|
| 23 | + * @param SiteConfig|null $siteConfig |
|
| 24 | 24 | * @return $this |
| 25 | 25 | */ |
| 26 | 26 | public function setSiteConfig($siteConfig) |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'product_id', |
| 121 | 121 | $this->product->ID))->setValue($this->product->ID)); |
| 122 | 122 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'price', |
| 123 | - $this->product->Price))->setValue($this->product->Price));//can't override id |
|
| 123 | + $this->product->Price))->setValue($this->product->Price)); //can't override id |
|
| 124 | 124 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'weight', |
| 125 | 125 | $this->product->Weight))->setValue($this->product->Weight)); |
| 126 | 126 | if ($this->DiscountTitle && $this->ProductDiscountTiers()->exists()) { |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $fields->push(DropdownField::create('quantity', 'Quantity', $quantity)); |
| 153 | 153 | |
| 154 | - $fields->push(HeaderField::create('submitPrice', '$' . $this->product->Price, 4)); |
|
| 154 | + $fields->push(HeaderField::create('submitPrice', '$'.$this->product->Price, 4)); |
|
| 155 | 155 | |
| 156 | 156 | |
| 157 | 157 | $this->extend('updatePurchaseFormFields', $fields); |
| 158 | - } else { |
|
| 158 | + }else { |
|
| 159 | 159 | $fields->push(HeaderField::create('submitPrice', 'Currently Out of Stock'), 4); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | protected function getProductOptionSet() |
| 193 | 193 | { |
| 194 | 194 | |
| 195 | - $assignAvailable = function ($self) { |
|
| 195 | + $assignAvailable = function($self) { |
|
| 196 | 196 | $this->extend('updateFoxyStripePurchaseForm', $form); |
| 197 | 197 | $self->Available = ($self->getAvailability()) ? true : false; |
| 198 | 198 | }; |