Skip to content

Commit

Permalink
Merge pull request #224 from magento-folks/bugs
Browse files Browse the repository at this point in the history
[Folks] Bugfix
  • Loading branch information
Shkolyarenko, Serhiy(sshkolyarenko) authored and Shkolyarenko, Serhiy(sshkolyarenko) committed Dec 7, 2015
2 parents 7b831ff + 86cf64f commit 8c60b4b
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<item name="component" xsi:type="string">Magento_Checkout/js/view/cart/shipping-estimation</item>
<item name="provider" xsi:type="string">checkoutProvider</item>
<item name="sortOrder" xsi:type="string">1</item>
<item name="deps" xsi:type="array">
<item name="0" xsi:type="string">block-summary.block-shipping.address-fieldsets</item>
</item>
<item name="children" xsi:type="array">
<item name="address-fieldsets" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function _prepareForm()

if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField(
'store_id',
'stores',
'multiselect',
[
'name' => 'stores[]',
Expand All @@ -137,7 +137,7 @@ protected function _prepareForm()
$field->setRenderer($renderer);
} else {
$fieldset->addField(
'store_id',
'stores',
'hidden',
['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ protected function _prepareColumns()

if (!$this->_storeManager->isSingleStoreMode()) {
$this->addColumn(
'store_id',
'stores',
[
'header' => __('Store View'),
'index' => 'store_id',
'index' => 'stores',
'type' => 'store',
'store_all' => true,
'store_view' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function save(\Magento\CheckoutAgreements\Api\Data\AgreementInterface $da
if ($storeId === null) {
$storeId = $this->storeManager->getStore()->getId();
}
$data->setStores($storeId);
$data->setStores([$storeId]);
try {
$this->resourceModel->save($data);
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
*/
protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
{
$condition = ['agreement_id = ?' => $object->getId()];
$this->getConnection()->delete($this->getTable('checkout_agreement_store'), $condition);
$this->getConnection()->delete(
$this->getTable('checkout_agreement_store'),
['agreement_id = ?' => $object->getId()]
);

foreach ((array)$object->getData('stores') as $store) {
$storeArray = [];
$storeArray['agreement_id'] = $object->getId();
$storeArray['store_id'] = $store;
foreach ((array)$object->getData('stores') as $storeId) {
$storeArray = [
'agreement_id' => $object->getId(),
'store_id' => $storeId
];
$this->getConnection()->insert($this->getTable('checkout_agreement_store'), $storeArray);
}

Expand All @@ -96,8 +99,10 @@ protected function _afterLoad(\Magento\Framework\Model\AbstractModel $object)
->from($this->getTable('checkout_agreement_store'), ['store_id'])
->where('agreement_id = :agreement_id');

if ($stores = $this->getConnection()->fetchCol($select, [':agreement_id' => $object->getId()])) {
$object->setData('store_id', $stores);
$stores = $this->getConnection()->fetchCol($select, [':agreement_id' => $object->getId()]);

if ($stores) {
$object->setData('stores', $stores);
}

return parent::_afterLoad($object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<!-- /ko -->
<!-- /ko -->
<div id="checkout-agreements-modal" data-bind="afterRender: initModal" style="display: none">
<div class="checkout-agreements-item-title" data-bind="html: modalTitle"></div>
<div class="checkout-agreements-item-content" data-bind="html: modalContent"></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function setUp()
);
$this->messageMock = $this->getMock('Magento\GiftMessage\Model\Message', [], [], '', false);
$this->quoteItemMock = $this->getMock(
'\Magento\Qote\Model\Quote\Item',
'\Magento\Quote\Model\Quote\Item',
[
'getGiftMessageId',
'__wakeup'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function setUp()
);
$this->messageMock = $this->getMock('Magento\GiftMessage\Model\Message', [], [], '', false);
$this->quoteItemMock = $this->getMock(
'\Magento\Qote\Model\Quote\Item',
'\Magento\Quote\Model\Quote\Item',
[
'getGiftMessageId',
'__wakeup'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ define([
hasActiveOptions: function() {
var regionData = this.getRegion('additionalOptions');
var options = regionData();
for (var i in options) {
for (var i = 0; i < options.length; i++) {
if (options[i].isActive()) {
return true;
}
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/Quote/etc/webapi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@
<resource ref="Magento_Cart::manage" />
</resources>
</route>
<route url="/V1/carts/:cartId/estimate-shipping-methods" method="POST">
<service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="estimateByAddress"/>
<resources>
<resource ref="Magento_Cart::manage" />
</resources>
</route>
<route url="/V1/carts/:cartId/estimate-shipping-methods-by-address-id" method="POST">
<service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="estimateByAddressId"/>
<resources>
<resource ref="Magento_Cart::manage" />
</resources>
</route>

<!-- Managing My Cart Shipment Method -->
<route url="/V1/carts/mine/shipping-methods" method="GET">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<data name="configData" xsi:type="string">authorizenet</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
</variation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Shipping extends Form

/**
* Fields that are used in estimation shipping form.
* Indexes of this array should be numeric, they are used in compare() method.
*
* @var array
*/
Expand Down Expand Up @@ -102,6 +103,21 @@ public function fillEstimateShippingAndTax(Address $address)
$this->openEstimateShippingAndTax();
$data = $address->getData();
$mapping = $this->dataMapping(array_intersect_key($data, array_flip($this->estimationFields)));
// sort array according to $this->estimationFields elements order
uksort($mapping, function ($a, $b) {
$a = array_search($a, $this->estimationFields);
$b = array_search($b, $this->estimationFields);
switch (true) {
case false !== $a && false !== $b:
return $a - $b;
case false !== $a:
return -1;
case false !== $b:
return 1;
default:
return 0;
}
});

// Test environment may become unstable when form fields are filled in a default manner.
// Imitating behavior closer to the real user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ class Sidebar extends Block
*/
protected $cartLink = 'a.showcart';

/**
* Minicart items quantity
*
* @var string
*/
protected $productCounter = './/*[@class="counter-number"]';

/**
* Empty minicart message
*
* @var string
*/
protected $emptyCartMessage = './/*[@id="minicart-content-wrapper"]//*[@class="subtitle empty"]';

/**
* Mini cart content selector.
*
Expand Down Expand Up @@ -101,6 +115,27 @@ function () use ($browser, $selector) {
);
}

/**
* Get empty minicart message
*
* @return string
*/
public function getEmptyMessage()
{
$this->_rootElement->find($this->cartLink)->click();
return $this->_rootElement->find($this->emptyCartMessage, Locator::SELECTOR_XPATH)->getText();
}

/**
* Is minicart items quantity block visible
*
* @return bool
*/
public function isItemsQtyVisible()
{
return $this->_rootElement->find($this->productCounter, Locator::SELECTOR_XPATH)->isVisible();
}

/**
* Get product quantity.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Checkout\Test\Constraint;

use Magento\Cms\Test\Page\CmsIndex;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Assert that customer cart is empty
*/
class AssertMinicartEmpty extends AbstractConstraint
{
/**
* Empty cart message
*/
const TEXT_EMPTY_MINICART = 'You have no items in your shopping cart.';

/**
* Assert that customer minicart is empty
*
* @param CmsIndex $cmsIndex
*/
public function processAssert(
CmsIndex $cmsIndex
) {
\PHPUnit_Framework_Assert::assertEquals(
self::TEXT_EMPTY_MINICART,
$cmsIndex->getCartSidebarBlock()->getEmptyMessage(),
'Empty minicart message not found'
);

\PHPUnit_Framework_Assert::assertFalse(
$cmsIndex->getCartSidebarBlock()->isItemsQtyVisible(),
'Minicart is not empty'
);
}

/**
* Returns a string representation of the object
*
* @return string
*/
public function toString()
{
return 'Minicart is empty';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Invoice, Edit</data>
<data name="configData" xsi:type="string">checkmo_specificcountry_gb</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
Expand All @@ -40,6 +41,7 @@
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Ship, Invoice, Edit</data>
<data name="configData" xsi:type="string">banktransfer</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
Expand All @@ -59,6 +61,7 @@
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Ship, Invoice, Edit</data>
<data name="configData" xsi:type="string">banktransfer_specificcountry_gb</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
Expand All @@ -81,6 +84,7 @@
<data name="tag" xsi:type="string">test_type:acceptance_test</data>
<data name="configData" xsi:type="string">checkmo</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage"/>
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal"/>
</variation>
<variation name="OnePageCheckoutTestVariation5" summary="Guest Checkout using Check/Money Order and Free Shipping with Prices/Taxes Verifications" ticketId="MAGETWO-12412">
Expand All @@ -102,6 +106,7 @@
<data name="configData" xsi:type="string">checkmo, freeshipping_minimum_order_amount_100</data>
<data name="tag" xsi:type="string">test_type:acceptance_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage"/>
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal"/>
</variation>
</testCase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<data name="configData" xsi:type="string">checkmo, dhl_eu, shipping_origin_CH, config_base_currency_ch</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" />
<constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" />
</variation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<data name="configData" xsi:type="string">checkmo, fedex, shipping_origin_US_CA</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" />
<constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" />
</variation>
Expand All @@ -36,6 +37,7 @@
<data name="configData" xsi:type="string">checkmo, fedex, shipping_origin_US_CA</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" />
<constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" />
</variation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<data name="giftMessage/data/message" xsi:type="string">text_gift_message</data>
<data name="payment/method" xsi:type="string">cashondelivery</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrder" />
</variation>
<variation name="CheckoutWithGiftMessagesTestVariation2">
Expand All @@ -40,6 +41,7 @@
<data name="giftMessage/data/items/datasets" xsi:type="string">default</data>
<data name="payment/method" xsi:type="string">cashondelivery</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\GiftMessage\Test\Constraint\AssertGiftMessageInFrontendOrderItems" />
</variation>
</testCase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<data name="configData" xsi:type="string">paypal_express, freeshipping</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
</variation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<data name="configData" xsi:type="string">payflowpro</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
</variation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<data name="configData" xsi:type="string">paypal_express</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
</variation>
Expand Down Expand Up @@ -57,6 +58,7 @@
<data name="configData" xsi:type="string">payflowlink</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
</variation>
Expand Down Expand Up @@ -84,6 +86,7 @@
<data name="configData" xsi:type="string">paypal_express</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCommentsHistory" />
</variation>
Expand Down
Loading

0 comments on commit 8c60b4b

Please sign in to comment.