diff --git a/README.md b/README.md
index 74f3a517570d0..4994ea453c675 100644
--- a/README.md
+++ b/README.md
@@ -3,61 +3,14 @@
Welcome
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results.
-The installation instructions that used to be here are now published on our GitHub site. Use the information on this page to get started or go directly to the guide.
+## Magento system requirements
+[Magento system requirements](http://devdocs.magento.com/magento-system-requirements.html)
-New to Magento? Need some help?
-If you're not sure about the following, you probably need a little help before you start installing the Magento software:
+## Install Magento
+To install Magento, see either:
-* Is the Magento software installed already?
-* What's a terminal, command prompt, or Secure Shell (ssh)?
-* Where's my Magento server and how do I access it?
-* What's PHP?
-* What's Apache?
-* What's MySQL?
-
-Step 1: Verify your prerequisites
-
-Use the following table to verify you have the correct prerequisites to install the Magento software.
-
-
-
-
- Prerequisite |
- How to check |
- For more information |
-
-
- Apache 2.2 or 2.4 |
- Ubuntu: apache2 -v
- CentOS: httpd -v |
- Apache |
-
-
- PHP 5.6.x, 7.0.2, 7.0.4 or 7.0.6 |
- php -v |
- PHP Ubuntu PHP CentOS |
-
- MySQL 5.6.x |
- mysql -u [root user name] -p |
- MySQL |
-
-
-
-
-Step 2: Prepare to install
-
-After verifying your prerequisites, perform the following tasks in order to prepare to install the Magento software.
-
-1. Install Composer
-2. Clone the Magento repository
-
-Step 3: Install and verify the installation
-
-1. Update installation dependencies
-2. Install Magento:
- * Install Magento software using the web interface
- * Install Magento software using the command line
-2. Verify the installation
+* [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento.
+* [Installation guide](http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html)
Contributing to the Magento 2 code base
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php
index af9dded435a7f..5247105a1cf6e 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Backend\Block\Dashboard\Tab\Products;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Pricing\Price\FinalPrice;
+
/**
* Adminhtml dashboard most viewed products grid
*
@@ -66,8 +69,14 @@ protected function _prepareCollection()
);
$this->setCollection($collection);
+ parent::_prepareCollection();
+
+ /** @var Product $product */
+ foreach ($collection as $product) {
+ $product->setPrice($product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
+ }
- return parent::_prepareCollection();
+ return $this;
}
/**
diff --git a/app/code/Magento/Backend/i18n/en_US.csv b/app/code/Magento/Backend/i18n/en_US.csv
index 252269ba97ffb..9144df6c8f7d9 100644
--- a/app/code/Magento/Backend/i18n/en_US.csv
+++ b/app/code/Magento/Backend/i18n/en_US.csv
@@ -250,7 +250,7 @@ Minute,Minute
"JavaScript may be disabled in your browser.","JavaScript may be disabled in your browser."
"To use this website you must first enable JavaScript in your browser.","To use this website you must first enable JavaScript in your browser."
"This is only a demo store. You can browse and place orders, but nothing will be processed.","This is only a demo store. You can browse and place orders, but nothing will be processed."
-"Report Bugs","Report Bugs"
+"Report a Bug","Report a Bug"
"Store View:","Store View:"
"Stores Configuration","Stores Configuration"
"Please confirm scope switching. All data that hasn\'t been saved will be lost.","Please confirm scope switching. All data that hasn\'t been saved will be lost."
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml
index a437c77ca48f0..ef96cb1f87b60 100644
--- a/app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml
@@ -8,5 +8,5 @@
?>
getBugreportUrl()): ?>
-
+
diff --git a/app/code/Magento/Catalog/Model/ProductWebsiteLinkRepository.php b/app/code/Magento/Catalog/Model/ProductWebsiteLinkRepository.php
index 55469ccf03898..30b84c816e101 100644
--- a/app/code/Magento/Catalog/Model/ProductWebsiteLinkRepository.php
+++ b/app/code/Magento/Catalog/Model/ProductWebsiteLinkRepository.php
@@ -37,7 +37,7 @@ public function save(ProductWebsiteLinkInterface $productWebsiteLink)
$product = $this->productRepository->get($productWebsiteLink->getSku());
$product->setWebsiteIds(array_merge($product->getWebsiteIds(), [$productWebsiteLink->getWebsiteId()]));
try {
- $product->save();
+ $this->productRepository->save($product);
} catch (\Exception $e) {
throw new CouldNotSaveException(
__(
@@ -68,7 +68,7 @@ public function deleteById($sku, $websiteId)
$product->setWebsiteIds(array_diff($product->getWebsiteIds(), [$websiteId]));
try {
- $product->save();
+ $this->productRepository->save($product);
} catch (\Exception $e) {
throw new CouldNotSaveException(
__(
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php
index 52e9d83f40db6..a029e2cd0d1f9 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php
@@ -98,15 +98,15 @@ public function build($productId)
->limit(1);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
- $priceSelectDefault = clone $priceSelect;
- $priceSelectDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
- $select[] = $priceSelectDefault;
-
if (!$this->catalogHelper->isPriceGlobal()) {
- $priceSelect->where('t.store_id = ?', $this->storeManager->getStore()->getId());
- $select[] = $priceSelect;
+ $priceSelectStore = clone $priceSelect;
+ $priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
+ $selects[] = $priceSelectStore;
}
- return $select;
+ $priceSelect->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
+ $selects[] = $priceSelect;
+
+ return $selects;
}
}
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php
index e202a6846edaf..17ce55b1252d6 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php
@@ -142,15 +142,15 @@ public function build($productId)
->limit(1);
$specialPrice = $this->baseSelectProcessor->process($specialPrice);
- $specialPriceDefault = clone $specialPrice;
- $specialPriceDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
- $select[] = $specialPriceDefault;
-
if (!$this->catalogHelper->isPriceGlobal()) {
- $specialPrice->where('t.store_id = ?', $this->storeManager->getStore()->getId());
- $select[] = $specialPrice;
+ $priceSelectStore = clone $specialPrice;
+ $priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
+ $selects[] = $priceSelectStore;
}
- return $select;
+ $specialPrice->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
+ $selects[] = $specialPrice;
+
+ return $selects;
}
}
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php
index bd6f9ff198b2d..b884d2504a47a 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php
@@ -100,15 +100,15 @@ public function build($productId)
->limit(1);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
- $priceSelectDefault = clone $priceSelect;
- $priceSelectDefault->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
- $select[] = $priceSelectDefault;
-
if (!$this->catalogHelper->isPriceGlobal()) {
- $priceSelect->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
- $select[] = $priceSelect;
+ $priceSelectStore = clone $priceSelect;
+ $priceSelectStore->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
+ $selects[] = $priceSelectStore;
}
- return $select;
+ $priceSelect->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
+ $selects[] = $priceSelect;
+
+ return $selects;
}
}
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php
index 377a4d6429e54..1ba05e55fe2b1 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php
@@ -26,11 +26,11 @@ public function __construct($linkedProductSelectBuilder)
*/
public function build($productId)
{
- $select = [];
+ $selects = [];
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
- $select = array_merge($select, $productSelectBuilder->build($productId));
+ $selects = array_merge($selects, $productSelectBuilder->build($productId));
}
- return $select;
+ return $selects;
}
}
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Website/SelectProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Website/SelectProcessor.php
new file mode 100644
index 0000000000000..65e94d7178ae8
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Website/SelectProcessor.php
@@ -0,0 +1,67 @@
+metadataPool = $metadataPool;
+ $this->resource = $resource;
+ $this->storeManager = $storeManager;
+ }
+
+ /**
+ * Joins website-product relation table to filter products that are only in current website
+ *
+ * {@inheritdoc}
+ */
+ public function process(Select $select)
+ {
+ $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
+ $select->joinInner(
+ ['pw' => $this->resource->getTableName('catalog_product_website')],
+ 'pw.product_id = ' . BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS . '.' . $linkField
+ . ' AND pw.website_id = ' . $this->storeManager->getWebsite()->getId(),
+ []
+ );
+
+ return $select;
+ }
+}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index f5dfee60bb45e..8ce6b1785171c 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -851,7 +851,7 @@
-
+
@@ -859,6 +859,18 @@
+
+
+
+ - Magento\Catalog\Model\ResourceModel\Product\Website\SelectProcessor
+
+
+
+
+
+ Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor
+
+
diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js
index d15c7b48dc409..f73c85cf5a827 100644
--- a/app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js
+++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js
@@ -54,17 +54,27 @@ define([
if (!data) {
return;
}
- data.each(function (item) {
+ _.each(data, function (item) {
if (!item.options) {
return;
}
- item.options.each(function (option) {
+ _.each(item.options, function (option) {
currentOption = utils.copy(option);
if (currentOption.hasOwnProperty('sort_order')) {
delete currentOption['sort_order'];
}
- currentOption['option_id'] = ++maxId;
+
+ if (currentOption.hasOwnProperty('option_id')) {
+ delete currentOption['option_id'];
+ }
+
+ if (currentOption.values.length > 0) {
+ _.each(currentOption.values, function (optionValue) {
+ delete optionValue['option_id'];
+ delete optionValue['option_type_id'];
+ });
+ }
options.push(currentOption);
});
});
@@ -73,7 +83,7 @@ define([
return;
}
this.cacheGridData = options;
- options.each(function (opt) {
+ _.each(options, function (opt) {
this.mappingValue(opt);
}, this);
diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
index 6e17705f4c464..640ad1c3d8d3d 100644
--- a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
+++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
@@ -67,11 +67,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Block/Cart/Shipping.php b/app/code/Magento/Checkout/Block/Cart/Shipping.php
index a7f808b9ccb5e..147dc08a49d99 100644
--- a/app/code/Magento/Checkout/Block/Cart/Shipping.php
+++ b/app/code/Magento/Checkout/Block/Cart/Shipping.php
@@ -20,6 +20,11 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
*/
protected $layoutProcessors;
+ /**
+ * @var \Magento\Framework\Serialize\Serializer\Json
+ */
+ private $serializer;
+
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Model\Session $customerSession
@@ -27,7 +32,8 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
* @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider
* @param array $layoutProcessors
* @param array $data
- * @codeCoverageIgnore
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
+ * @throws \RuntimeException
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
@@ -35,12 +41,15 @@ public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Checkout\Model\CompositeConfigProvider $configProvider,
array $layoutProcessors = [],
- array $data = []
+ array $data = [],
+ \Magento\Framework\Serialize\Serializer\Json $serializer = null
) {
$this->configProvider = $configProvider;
$this->layoutProcessors = $layoutProcessors;
parent::__construct($context, $customerSession, $checkoutSession, $data);
$this->_isScopePrivate = true;
+ $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(\Magento\Framework\Serialize\Serializer\Json::class);
}
/**
@@ -64,7 +73,7 @@ public function getJsLayout()
foreach ($this->layoutProcessors as $processor) {
$this->jsLayout = $processor->process($this->jsLayout);
}
- return \Zend_Json::encode($this->jsLayout);
+ return $this->serializer->serialize($this->jsLayout);
}
/**
@@ -77,4 +86,12 @@ public function getBaseUrl()
{
return $this->_storeManager->getStore()->getBaseUrl();
}
+
+ /**
+ * @return bool|string
+ */
+ public function getSerializedCheckoutConfig()
+ {
+ return $this->serializer->serialize($this->getCheckoutConfig());
+ }
}
diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar.php b/app/code/Magento/Checkout/Block/Cart/Sidebar.php
index 23508bc138de8..88fc2b81aa589 100644
--- a/app/code/Magento/Checkout/Block/Cart/Sidebar.php
+++ b/app/code/Magento/Checkout/Block/Cart/Sidebar.php
@@ -27,6 +27,11 @@ class Sidebar extends AbstractCart
*/
protected $imageHelper;
+ /**
+ * @var \Magento\Framework\Serialize\Serializer\Json
+ */
+ private $serializer;
+
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Model\Session $customerSession
@@ -34,7 +39,8 @@ class Sidebar extends AbstractCart
* @param \Magento\Catalog\Helper\Image $imageHelper
* @param \Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface $jsLayoutDataProvider
* @param array $data
- * @codeCoverageIgnore
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
+ * @throws \RuntimeException
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
@@ -42,7 +48,8 @@ public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Catalog\Helper\Image $imageHelper,
\Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface $jsLayoutDataProvider,
- array $data = []
+ array $data = [],
+ \Magento\Framework\Serialize\Serializer\Json $serializer = null
) {
if (isset($data['jsLayout'])) {
$this->jsLayout = array_merge_recursive($jsLayoutDataProvider->getData(), $data['jsLayout']);
@@ -53,6 +60,8 @@ public function __construct(
parent::__construct($context, $customerSession, $checkoutSession, $data);
$this->_isScopePrivate = false;
$this->imageHelper = $imageHelper;
+ $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(\Magento\Framework\Serialize\Serializer\Json::class);
}
/**
@@ -75,6 +84,14 @@ public function getConfig()
];
}
+ /**
+ * @return string
+ */
+ public function getSerializedConfig()
+ {
+ return $this->serializer->serialize($this->getConfig());
+ }
+
/**
* @return string
*/
diff --git a/app/code/Magento/Checkout/Block/Onepage.php b/app/code/Magento/Checkout/Block/Onepage.php
index 15e913d9338d0..29493cab6f517 100644
--- a/app/code/Magento/Checkout/Block/Onepage.php
+++ b/app/code/Magento/Checkout/Block/Onepage.php
@@ -36,19 +36,27 @@ class Onepage extends \Magento\Framework\View\Element\Template
*/
protected $layoutProcessors;
+ /**
+ * @var \Magento\Framework\Serialize\Serializer\Json
+ */
+ private $serializer;
+
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Data\Form\FormKey $formKey
* @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider
* @param array $layoutProcessors
* @param array $data
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
+ * @throws \RuntimeException
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Data\Form\FormKey $formKey,
\Magento\Checkout\Model\CompositeConfigProvider $configProvider,
array $layoutProcessors = [],
- array $data = []
+ array $data = [],
+ \Magento\Framework\Serialize\Serializer\Json $serializer = null
) {
parent::__construct($context, $data);
$this->formKey = $formKey;
@@ -56,6 +64,8 @@ public function __construct(
$this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : [];
$this->configProvider = $configProvider;
$this->layoutProcessors = $layoutProcessors;
+ $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(\Magento\Framework\Serialize\Serializer\Json::class);
}
/**
@@ -66,7 +76,7 @@ public function getJsLayout()
foreach ($this->layoutProcessors as $processor) {
$this->jsLayout = $processor->process($this->jsLayout);
}
- return \Zend_Json::encode($this->jsLayout);
+ return $this->serializer->serialize($this->jsLayout);
}
/**
@@ -101,4 +111,12 @@ public function getBaseUrl()
{
return $this->_storeManager->getStore()->getBaseUrl();
}
+
+ /**
+ * @return bool|string
+ */
+ public function getSerializedCheckoutConfig()
+ {
+ return $this->serializer->serialize($this->getCheckoutConfig());
+ }
}
diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php
index 8313695ff8e76..7941889f37ac1 100644
--- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php
@@ -47,6 +47,11 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
*/
protected $layout;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $serializer;
+
protected function setUp()
{
$this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false);
@@ -69,6 +74,7 @@ protected function setUp()
$this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
$this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager);
+ $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
$this->model = new \Magento\Checkout\Block\Cart\Shipping(
$this->context,
@@ -76,7 +82,8 @@ protected function setUp()
$this->checkoutSession,
$this->configProvider,
[$this->layoutProcessor],
- ['jsLayout' => $this->layout]
+ ['jsLayout' => $this->layout],
+ $this->serializer
);
}
@@ -91,13 +98,18 @@ public function testGetJsLayout()
{
$layoutProcessed = $this->layout;
$layoutProcessed['components']['thirdComponent'] = ['param' => 'value'];
+ $jsonLayoutProcessed = json_encode($layoutProcessed);
$this->layoutProcessor->expects($this->once())
->method('process')
->with($this->layout)
->willReturn($layoutProcessed);
+
+ $this->serializer->expects($this->once())->method('serialize')->will(
+ $this->returnValue($jsonLayoutProcessed)
+ );
$this->assertEquals(
- \Zend_Json::encode($layoutProcessed),
+ $jsonLayoutProcessed,
$this->model->getJsLayout()
);
}
@@ -110,4 +122,15 @@ public function testGetBaseUrl()
$this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
$this->assertEquals($baseUrl, $this->model->getBaseUrl());
}
+
+ public function testGetSerializedCheckoutConfig()
+ {
+ $checkoutConfig = ['checkout', 'config'];
+ $this->configProvider->expects($this->once())->method('getConfig')->willReturn($checkoutConfig);
+ $this->serializer->expects($this->once())->method('serialize')->will(
+ $this->returnValue(json_encode($checkoutConfig))
+ );
+
+ $this->assertEquals(json_encode($checkoutConfig), $this->model->getSerializedCheckoutConfig());
+ }
}
diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php
index d282ed89148be..d183ef67bcc30 100644
--- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php
@@ -53,6 +53,11 @@ class SidebarTest extends \PHPUnit_Framework_TestCase
*/
protected $requestMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $serializer;
+
protected function setUp()
{
$this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -94,12 +99,15 @@ protected function setUp()
->method('getRequest')
->will($this->returnValue($this->requestMock));
+ $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
+
$this->model = $this->_objectManager->getObject(
\Magento\Checkout\Block\Cart\Sidebar::class,
[
'context' => $contextMock,
'imageHelper' => $this->imageHelper,
- 'checkoutSession' => $this->checkoutSessionMock
+ 'checkoutSession' => $this->checkoutSessionMock,
+ 'serializer' => $this->serializer
]
);
}
diff --git a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php
index 47fddfeb4a827..9bfdee8ccd645 100644
--- a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php
@@ -32,6 +32,11 @@ class OnepageTest extends \PHPUnit_Framework_TestCase
*/
protected $layoutProcessorMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $serializer;
+
protected function setUp()
{
$contextMock = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false);
@@ -54,11 +59,15 @@ protected function setUp()
false
);
+ $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
+
$this->model = new \Magento\Checkout\Block\Onepage(
$contextMock,
$this->formKeyMock,
$this->configProviderMock,
- [$this->layoutProcessorMock]
+ [$this->layoutProcessorMock],
+ [],
+ $this->serializer
);
}
@@ -94,7 +103,21 @@ public function testGetJsLayout()
$processedLayout = ['layout' => ['processed' => true]];
$jsonLayout = '{"layout":{"processed":true}}';
$this->layoutProcessorMock->expects($this->once())->method('process')->with([])->willReturn($processedLayout);
+ $this->serializer->expects($this->once())->method('serialize')->will(
+ $this->returnValue(json_encode($processedLayout))
+ );
$this->assertEquals($jsonLayout, $this->model->getJsLayout());
}
+
+ public function testGetSerializedCheckoutConfig()
+ {
+ $checkoutConfig = ['checkout', 'config'];
+ $this->configProviderMock->expects($this->once())->method('getConfig')->willReturn($checkoutConfig);
+ $this->serializer->expects($this->once())->method('serialize')->will(
+ $this->returnValue(json_encode($checkoutConfig))
+ );
+
+ $this->assertEquals(json_encode($checkoutConfig), $this->model->getSerializedCheckoutConfig());
+ }
}
diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml
index ae68b530d67f6..d7596413d4122 100644
--- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml
+++ b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml
@@ -43,7 +43,7 @@