Skip to content

Commit

Permalink
Merge pull request #667 from magento-fearless-kiwis/MAGETWO-62202
Browse files Browse the repository at this point in the history
[Kiwi] Prepare code base for 2.0.12
  • Loading branch information
Oleksii Korshenko authored Dec 13, 2016
2 parents 3d7e5bc + eb7569d commit c7bdfaa
Show file tree
Hide file tree
Showing 93 changed files with 1,991 additions and 497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function placeCheckoutOrder()
);
} catch (\Exception $exception) {
$result->setData('error', true);
$result->setData('error_messages', __('Cannot place order.'));
$result->setData('error_messages', __('Unable to place order. Please try again later.'));
}
if ($response instanceof Http) {
$response->representJson($this->jsonHelper->jsonEncode($result));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function textExecuteFailedPlaceOrderDataProvider()
{
$objectFailed = new \Magento\Framework\DataObject();
$objectFailed->setData('error', true);
$objectFailed->setData('error_messages', __('Cannot place order.'));
$objectFailed->setData('error_messages', __('Unable to place order. Please try again later.'));

return [
[
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Authorizenet/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"magento/framework": "100.0.*"
},
"type": "magento2-module",
"version": "100.0.6",
"version": "100.0.7",
"license": [
"proprietary"
],
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Authorizenet/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Cancel,Cancel
"Something went wrong canceling the transactions.","Something went wrong canceling the transactions."
"There was an error canceling transactions. Please contact us or try again later.","There was an error canceling transactions. Please contact us or try again later."
"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later."
"Unable to place order. Please try again later.","Unable to place order. Please try again later."
"amount %1","amount %1"
failed,failed
successful,successful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
);
}

if (!$websiteModel->getIsDefault() && $websiteModel->getStoresCount()) {
if ($this->checkIsSingleAndIsDefaultStore($websiteModel)) {
$fieldset->addField(
'is_default',
'checkbox',
Expand All @@ -133,4 +133,12 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
['name' => 'website[website_id]', 'value' => $websiteModel->getId()]
);
}

private function checkIsSingleAndIsDefaultStore($websiteModel)
{
$hasOnlyDefaultStore = $websiteModel->getStoresCount() == 1 &&
isset($websiteModel->getStoreIds()[\Magento\Store\Model\Store::DEFAULT_STORE_ID]);

return !$websiteModel->getIsDefault() && $websiteModel->getStoresCount() && !$hasOnlyDefaultStore;
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Braintree/Model/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public function assignData(\Magento\Framework\DataObject $data)

$infoInstance->setAdditionalInformation('cc_last4', $additionalData->getData('cc_last4'));
$infoInstance->setAdditionalInformation('cc_token', $additionalData->getData('cc_token'));
$infoInstance->setAdditionalInformation('store_in_vault', $additionalData->getData('store_in_vault'));
$infoInstance->setAdditionalInformation(
'payment_method_nonce',
$additionalData->getData('payment_method_nonce')
Expand Down
28 changes: 18 additions & 10 deletions app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,25 @@ public function testAssignData()
->with($ccExpYear)
->willReturnSelf();

$this->infoInstanceMock->expects($this->atLeastOnce())
$this->infoInstanceMock->expects($this->at(0))
->method('setAdditionalInformation')
->willReturnMap(
[
['device_data', $deviceData],
['cc_last4', $ccLast4],
['cc_token', $ccToken],
['payment_method_nonce', $paymentMethodNonce],
['store_in_vault', $storeInVault]
]
);
->with('device_data', $deviceData);

$this->infoInstanceMock->expects($this->at(1))
->method('setAdditionalInformation')
->with('cc_last4', $ccLast4);

$this->infoInstanceMock->expects($this->at(2))
->method('setAdditionalInformation')
->with('cc_token', $ccToken);

$this->infoInstanceMock->expects($this->at(3))
->method('setAdditionalInformation')
->with('store_in_vault', $storeInVault);

$this->infoInstanceMock->expects($this->at(4))
->method('setAdditionalInformation')
->with('payment_method_nonce', $paymentMethodNonce);

$this->model->assignData($data);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Braintree/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"magento/module-checkout-agreements": "100.0.*"
},
"type": "magento2-module",
"version": "100.0.7",
"version": "100.0.8",
"license": [
"proprietary"
],
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/BundleImportExport/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"magento/framework": "100.0.*"
},
"type": "magento2-module",
"version": "100.0.5",
"version": "100.0.6",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/CacheInvalidate/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"magento/framework": "100.0.*"
},
"type": "magento2-module",
"version": "100.0.5",
"version": "100.0.6",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
20 changes: 11 additions & 9 deletions app/code/Magento/Catalog/Block/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,28 @@ public function getJsonConfig()
foreach ($tierPricesList as $tierPrice) {
$tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
}
$regularPriceAmount = $product->getPriceInfo()->getPrice('regular_price')->getAmount();
$finalPriceAmount = $product->getPriceInfo()->getPrice('final_price')->getAmount();
$config = [
'productId' => $product->getId(),
'priceFormat' => $this->_localeFormat->getPriceFormat(),
'prices' => [
'oldPrice' => [
'amount' => $this->priceCurrency->convert(
$product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue()
),
'amount' => $regularPriceAmount
? $this->priceCurrency->convert($regularPriceAmount->getValue())
: null,
'adjustments' => []
],
'basePrice' => [
'amount' => $this->priceCurrency->convert(
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount()
),
'amount' => $finalPriceAmount
? $this->priceCurrency->convert($finalPriceAmount->getBaseAmount())
: null,
'adjustments' => []
],
'finalPrice' => [
'amount' => $this->priceCurrency->convert(
$product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()
),
'amount' => $finalPriceAmount
? $this->priceCurrency->convert($finalPriceAmount->getValue())
: null,
'adjustments' => []
]
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Model\Product\Pricing\Renderer;

/**
* Resolver provided to check is product available for sale
*/
class SalableResolver implements SalableResolverInterface
{
/**
* Check is product available for sale
*
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
* @return boolean
*/
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem)
{
return $salableItem->getCanShowPrice() !== false && $salableItem->isSalable();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Model\Product\Pricing\Renderer;

/**
* Interface resolver provided to check is product available for sale
*/
interface SalableResolverInterface
{
/**
* Check is product available for sale
*
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
* @return boolean
*/
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem);
}
33 changes: 32 additions & 1 deletion app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
use Magento\Framework\Pricing\Render;
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;
use Magento\Msrp\Pricing\Price\MsrpPrice;
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Framework\Pricing\Price\PriceInterface;
use Magento\Framework\Pricing\Render\RendererPool;

/**
* Class for final_price rendering
Expand All @@ -19,12 +24,38 @@
*/
class FinalPriceBox extends BasePriceBox
{
/**
* @var SalableResolverInterface
*/
private $salableResolver;

/**
* @param Context $context
* @param SaleableInterface $saleableItem
* @param PriceInterface $price
* @param RendererPool $rendererPool
* @param array $data
* @param SalableResolverInterface $salableResolver
*/
public function __construct(
Context $context,
SaleableInterface $saleableItem,
PriceInterface $price,
RendererPool $rendererPool,
array $data = [],
SalableResolverInterface $salableResolver = null
) {
parent::__construct($context, $saleableItem, $price, $rendererPool, $data);
$this->salableResolver = $salableResolver ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(SalableResolverInterface::class);
}

/**
* @return string
*/
protected function _toHtml()
{
if (!$this->getSaleableItem() || $this->getSaleableItem()->getCanShowPrice() === false) {
if (!$this->salableResolver->isSalable($this->getSaleableItem())) {
return '';
}

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

namespace Magento\Catalog\Test\Unit\Model\Product\Pricing\Renderer;

class SalableResolverTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver
*/
protected $object;

/**
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
*/
protected $product;

protected function setUp()
{
$this->product = $this->getMock(
'Magento\Catalog\Model\Product',
['__wakeup', 'getCanShowPrice', 'isSalable'],
[],
'',
false
);

$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->object = $objectManager->getObject(
'Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver'
);
}

public function testSalableItem()
{
$this->product->expects($this->any())
->method('getCanShowPrice')
->willReturn(true);

$this->product->expects($this->any())->method('isSalable')->willReturn(true);

$result = $this->object->isSalable($this->product);
$this->assertTrue($result);
}

public function testNotSalableItem()
{
$this->product->expects($this->any())
->method('getCanShowPrice')
->willReturn(true);

$this->product->expects($this->any())->method('isSalable')->willReturn(false);

$result = $this->object->isSalable($this->product);
$this->assertFalse($result);
}
}
Loading

0 comments on commit c7bdfaa

Please sign in to comment.