Skip to content

Commit

Permalink
Merge pull request #535 from magento-folks/bugfix
Browse files Browse the repository at this point in the history
[Folks] Bugs:
- MAGETWO-59258 [Github] Override module-directory/etc/zip_codes.xml only the last code of a country gets included #6694
- MAGETWO-59512 [GitHub] Products in wishlist show $0.00 price #6866
- MAGETWO-59185 [GITHUB] Offline carrier configuration option "showmethod" does not appear in admin panel carrier configuration page #5693
- MAGETWO-59130 [Github] REST API with searchCriteria does not return category_ids #6127
- MAGETWO-57850 Unable to filter blocks using store view and block ID
- MAGETWO-57682 [GitHub] Checkout Agreement validation is broken on payment method change #6224
- MAGETWO-59573 Braintree JS error on checkout after applying 100% discount coupon with free shipping enabled
  • Loading branch information
slavvka authored Oct 26, 2016
2 parents 9666070 + 6a08fad commit bd1655b
Show file tree
Hide file tree
Showing 22 changed files with 252 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ define([
quote.totals.subscribe(function () {
if (self.grandTotalAmount !== quote.totals()['base_grand_total']) {
self.grandTotalAmount = quote.totals()['base_grand_total'];
self.reInitPayPal();
}
});

Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr

$collection->load();

$collection->addCategoryIds();
$searchResult = $this->searchResultsFactory->create();
$searchResult->setSearchCriteria($searchCriteria);
$searchResult->setItems($collection->getItems());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ public function testGetList()
->method('process')
->with($searchCriteriaMock, $collectionMock);
$collectionMock->expects($this->once())->method('load');
$collectionMock->expects($this->once())->method('addCategoryIds');
$collectionMock->expects($this->once())->method('getItems')->willReturn([$itemsMock]);
$collectionMock->expects($this->once())->method('getSize')->willReturn(128);
$searchResultsMock = $this->getMock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ define(
function ($) {
'use strict';
var checkoutConfig = window.checkoutConfig,
agreementsConfig = checkoutConfig ? checkoutConfig.checkoutAgreements : {};

var agreementsInputPath = '.payment-method._active div.checkout-agreements input';
agreementsConfig = checkoutConfig ? checkoutConfig.checkoutAgreements : {},
agreementsInputPath = '.payment-method._active div.checkout-agreements input';

return {
/**
Expand All @@ -23,26 +22,11 @@ define(
* @returns {boolean}
*/
validate: function() {
if (!agreementsConfig.isEnabled) {
return true;
}

if ($(agreementsInputPath).length == 0) {
if (!agreementsConfig.isEnabled || $(agreementsInputPath).length == 0) {
return true;
}

return $('#co-payment-form').validate({
errorClass: 'mage-error',
errorElement: 'div',
meta: 'validate',
errorPlacement: function (error, element) {
var errorPlacement = element;
if (element.is(':checkbox') || element.is(':radio')) {
errorPlacement = element.siblings('label').last();
}
errorPlacement.after(error);
}
}).element(agreementsInputPath);
return $.validator.validateSingleElement(agreementsInputPath, {errorElement: 'div'});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
<div class="checkout-agreements" data-bind="visible: isVisible">
<!-- ko foreach: agreements -->
<!-- ko if: ($parent.isAgreementRequired($data)) -->
<div class="checkout-agreement">
<input type="checkbox"
<div class="checkout-agreement required">
<input type="checkbox" class="required-entry"
data-bind="attr: {
'id': 'agreement_' + agreementId,
'name': 'agreement[' + agreementId + ']',
'value': agreementId
}"
data-validate="{required:true}" />
}"/>
<label data-bind="attr: {'for': 'agreement_' + agreementId}">
<button type="button"
class="action action-show"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function _construct()
{
$this->_init(\Magento\Cms\Model\Block::class, \Magento\Cms\Model\ResourceModel\Block::class);
$this->_map['fields']['store'] = 'store_table.store_id';
$this->_map['fields']['block_id'] = 'main_table.block_id';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
*
* @var array
*/
protected $_idAttributes = ['/config/zip' => 'countryCode'];
protected $_idAttributes = [
'/config/zip' => 'countryCode',
'/config/zip/codes/code' => 'id',
];

/**
* Construct the FileSystem Reader Class
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/OfflineShipping/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Show Method if Not Applicable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<frontend_class>shipping-skip-hide</frontend_class>
</field>
<field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Displayed Error Message</label>
Expand Down Expand Up @@ -146,6 +147,7 @@
<field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Show Method if Not Applicable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<frontend_class>shipping-skip-hide</frontend_class>
</field>
<field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Displayed Error Message</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ class ConfigurableProduct extends FinalPrice implements ConfiguredPriceInterface
*/
public function getValue()
{
$result = 0.;
/** @var \Magento\Wishlist\Model\Item\Option $customOption */
$customOption = $this->getProduct()->getCustomOption('simple_product');
if ($customOption) {
/** @var \Magento\Framework\Pricing\PriceInfoInterface $priceInfo */
$priceInfo = $customOption->getProduct()->getPriceInfo();
$result = $priceInfo->getPrice(self::PRICE_CODE)->getValue();
}
return max(0, $result);
$product = $customOption ? $customOption->getProduct() : $this->getProduct();
$price = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue();

return max(0, $price);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,30 @@
*/
namespace Magento\Wishlist\Test\Unit\Pricing\ConfiguredPrice;

use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct;

class ConfigurableProductTest extends \PHPUnit_Framework_TestCase
{
/**
* @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $saleableItem;

/**
* @var CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\Adjustment\CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $calculator;

/**
* @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceCurrency;

/**
* @var ConfigurableProduct
* @var \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct
*/
private $model;

/**
* @var PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceInfoMock;

Expand All @@ -49,17 +43,14 @@ protected function setUp()
'getCustomOption',
])
->getMockForAbstractClass();
$this->saleableItem->expects($this->once())
->method('getPriceInfo')
->willReturn($this->priceInfoMock);

$this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class)
->getMockForAbstractClass();

$this->priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class)
->getMockForAbstractClass();

$this->model = new ConfigurableProduct(
$this->model = new \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct(
$this->saleableItem,
null,
$this->calculator,
Expand All @@ -82,7 +73,7 @@ public function testGetValue()
->getMock();
$this->priceInfoMock->expects($this->once())
->method('getPrice')
->with(ConfigurableProduct::PRICE_CODE)
->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
->willReturn($priceMock);

$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
Expand All @@ -109,11 +100,28 @@ public function testGetValue()

public function testGetValueWithNoCustomOption()
{
$priceValue = 100;

$priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
->getMockForAbstractClass();
$priceMock->expects($this->once())
->method('getValue')
->willReturn($priceValue);

$this->saleableItem->expects($this->once())
->method('getCustomOption')
->with('simple_product')
->willReturn(null);

$this->assertEquals(0, $this->model->getValue());
$this->saleableItem->expects($this->once())
->method('getPriceInfo')
->willReturn($this->priceInfoMock);

$this->priceInfoMock->expects($this->once())
->method('getPrice')
->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
->willReturn($priceMock);

$this->assertEquals(100, $this->model->getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,18 @@ public function testGetList()

$this->assertNotNull($response['items'][0]['sku']);
$this->assertEquals('simple', $response['items'][0]['sku']);

$index = null;
foreach ($response['items'][0]['custom_attributes'] as $key => $customAttribute) {
if ($customAttribute['attribute_code'] == 'category_ids') {
$index = $key;
break;
}
}
$this->assertNotNull($index, 'Category information wasn\'t set');

$expectedResult = (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) ? ['string' => '2'] : ['2'];
$this->assertEquals($expectedResult, $response['items'][0]['custom_attributes'][$index]['value']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,25 @@
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
</variation>
<variation name="OnePageCheckoutWithDiscountTestVariation2" summary="Checkout with 100% discount and free shipping if Braintree through PayPal is enabled" ticketId="MAGETWO-59940">
<data name="description" xsi:type="string">Use saved for Braintree credit card on checkout</data>
<data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data>
<data name="customer/dataset" xsi:type="string">default</data>
<data name="salesRule" xsi:type="string">active_sales_rule_with_fixed_price_discount_coupon</data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="checkoutMethod" xsi:type="string">login</data>
<data name="shipping/shipping_service" xsi:type="string">Free Shipping</data>
<data name="shipping/shipping_method" xsi:type="string">Free</data>
<data name="payment/method" xsi:type="string">free</data>
<data name="prices" xsi:type="array">
<item name="grandTotal" xsi:type="string">0.00</item>
</data>
<data name="configData" xsi:type="string">braintree, braintree_use_vault, freeshipping</data>
<data name="status" xsi:type="string">Pending</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
*/
class AssertGrandTotalOrderReview extends AbstractConstraint
{
/**
* Wait element.
*
* @var string
*/
protected $waitElement = '.loading-mask';

/**
* Assert that Order Grand Total is correct on checkoutOnePage
*
Expand All @@ -23,6 +30,7 @@ class AssertGrandTotalOrderReview extends AbstractConstraint
*/
public function processAssert(CheckoutOnepage $checkoutOnepage, $grandTotal)
{
$checkoutOnepage->getReviewBlock()->waitForElementNotVisible($this->waitElement);
$checkoutReviewGrandTotal = $checkoutOnepage->getReviewBlock()->getGrandTotal();

\PHPUnit_Framework_Assert::assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ public function hoverProductBlock()
$this->_rootElement->find($this->price)->hover();
}

/**
* Returns product price
*
* @param string $currency
* @return string
*/
public function getPrice($currency = '$')
{
$price = $this->_rootElement->find($this->price)->getText();
return str_replace($currency, '', $price);
}

/**
* Get Wish List data for the Product.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Wishlist\Test\Constraint;

class AssertProductPriceIsNotZero extends \Magento\Mtf\Constraint\AbstractConstraint
{
/**
* Assert that product price is not zero in default wishlist.
*
* @param \Magento\Cms\Test\Page\CmsIndex $cmsIndex
* @param \Magento\Customer\Test\Page\CustomerAccountIndex $customerAccountIndex
* @param \Magento\Wishlist\Test\Page\WishlistIndex $wishlistIndex
* @param \Magento\Mtf\Fixture\InjectableFixture $product
*
* @return void
*/
public function processAssert(
\Magento\Cms\Test\Page\CmsIndex $cmsIndex,
\Magento\Customer\Test\Page\CustomerAccountIndex $customerAccountIndex,
\Magento\Wishlist\Test\Page\WishlistIndex $wishlistIndex,
\Magento\Mtf\Fixture\InjectableFixture $product
) {
$cmsIndex->getLinksBlock()->openLink('My Account');
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
$wishlistItem = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product);

\PHPUnit_Framework_Assert::assertNotEquals(
'0.00',
$wishlistItem->getPrice(),
$product->getName() . ' has zero price on Wish List page.'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Product price is not zero in default Wish List.';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ public function __prepare(Customer $customer)
*
* @param Customer $customer
* @param string $product
* @param bool $configure
* @return array
*/
public function test(Customer $customer, $product)
public function test(Customer $customer, $product, $configure = true)
{
$product = $this->createProducts($product)[0];

// Steps:
$this->loginCustomer($customer);
$this->addToWishlist([$product], true);
$this->addToWishlist([$product], $configure);

return ['product' => $product];
}
Expand Down
Loading

0 comments on commit bd1655b

Please sign in to comment.