Skip to content

Commit 92d2d0d

Browse files
author
Oleksii Korshenko
authored
Merge pull request magento#857 from magento-engcom/develop-prs
Public Pull Requests: magento#8518 magento#8514 magento#8481
2 parents ad9c8e3 + 1d80c33 commit 92d2d0d

File tree

12 files changed

+127
-21
lines changed

12 files changed

+127
-21
lines changed

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Minute,Minute
250250
"JavaScript may be disabled in your browser.","JavaScript may be disabled in your browser."
251251
"To use this website you must first enable JavaScript in your browser.","To use this website you must first enable JavaScript in your browser."
252252
"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."
253-
"Report Bugs","Report Bugs"
253+
"Report a Bug","Report a Bug"
254254
"Store View:","Store View:"
255255
"Stores Configuration","Stores Configuration"
256256
"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."

app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
?>
1010
<?php if ($block->getBugreportUrl()): ?>
11-
<a class="link-report" href="<?php /* @escapeNotVerified */ echo $block->getBugreportUrl(); ?>" id="footer_bug_tracking"><?php /* @escapeNotVerified */ echo __('Report Bugs') ?></a>
11+
<a class="link-report" href="<?php /* @escapeNotVerified */ echo $block->getBugreportUrl(); ?>" id="footer_bug_tracking"><?php /* @escapeNotVerified */ echo __('Report a Bug') ?></a>
1212
<?php endif; ?>

app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
<block class="Magento\Framework\View\Element\Template" name="product.info.form.options" as="options_container">
6868
<block class="Magento\Catalog\Block\Product\View" name="product.info.options.wrapper" as="product_options_wrapper" template="product/view/options/wrapper.phtml">
6969
<block class="Magento\Catalog\Block\Product\View\Options" name="product.info.options" as="product_options" template="product/view/options.phtml">
70-
<block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" as="default" template="product/view/options/type/default.phtml"/>
71-
<block class="Magento\Catalog\Block\Product\View\Options\Type\Text" as="text" template="product/view/options/type/text.phtml"/>
72-
<block class="Magento\Catalog\Block\Product\View\Options\Type\File" as="file" template="product/view/options/type/file.phtml"/>
73-
<block class="Magento\Catalog\Block\Product\View\Options\Type\Select" as="select" template="product/view/options/type/select.phtml"/>
74-
<block class="Magento\Catalog\Block\Product\View\Options\Type\Date" as="date" template="product/view/options/type/date.phtml"/>
70+
<block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.default" as="default" template="product/view/options/type/default.phtml"/>
71+
<block class="Magento\Catalog\Block\Product\View\Options\Type\Text" name="product.info.options.text" as="text" template="product/view/options/type/text.phtml"/>
72+
<block class="Magento\Catalog\Block\Product\View\Options\Type\File" name="product.info.options.file" as="file" template="product/view/options/type/file.phtml"/>
73+
<block class="Magento\Catalog\Block\Product\View\Options\Type\Select" name="product.info.options.select" as="select" template="product/view/options/type/select.phtml"/>
74+
<block class="Magento\Catalog\Block\Product\View\Options\Type\Date" name="product.info.options.date" as="date" template="product/view/options/type/date.phtml"/>
7575
</block>
7676
<block class="Magento\Framework\View\Element\Html\Calendar" name="html_calendar" as="html_calendar" template="Magento_Theme::js/calendar.phtml"/>
7777
</block>

app/code/Magento/Checkout/Block/Cart/Shipping.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,36 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
2020
*/
2121
protected $layoutProcessors;
2222

23+
/**
24+
* @var \Magento\Framework\Serialize\Serializer\Json
25+
*/
26+
private $serializer;
27+
2328
/**
2429
* @param \Magento\Framework\View\Element\Template\Context $context
2530
* @param \Magento\Customer\Model\Session $customerSession
2631
* @param \Magento\Checkout\Model\Session $checkoutSession
2732
* @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider
2833
* @param array $layoutProcessors
2934
* @param array $data
30-
* @codeCoverageIgnore
35+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
36+
* @throws \RuntimeException
3137
*/
3238
public function __construct(
3339
\Magento\Framework\View\Element\Template\Context $context,
3440
\Magento\Customer\Model\Session $customerSession,
3541
\Magento\Checkout\Model\Session $checkoutSession,
3642
\Magento\Checkout\Model\CompositeConfigProvider $configProvider,
3743
array $layoutProcessors = [],
38-
array $data = []
44+
array $data = [],
45+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
3946
) {
4047
$this->configProvider = $configProvider;
4148
$this->layoutProcessors = $layoutProcessors;
4249
parent::__construct($context, $customerSession, $checkoutSession, $data);
4350
$this->_isScopePrivate = true;
51+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
52+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
4453
}
4554

4655
/**
@@ -64,7 +73,7 @@ public function getJsLayout()
6473
foreach ($this->layoutProcessors as $processor) {
6574
$this->jsLayout = $processor->process($this->jsLayout);
6675
}
67-
return \Zend_Json::encode($this->jsLayout);
76+
return $this->serializer->serialize($this->jsLayout);
6877
}
6978

7079
/**
@@ -77,4 +86,12 @@ public function getBaseUrl()
7786
{
7887
return $this->_storeManager->getStore()->getBaseUrl();
7988
}
89+
90+
/**
91+
* @return bool|string
92+
*/
93+
public function getSerializedCheckoutConfig()
94+
{
95+
return $this->serializer->serialize($this->getCheckoutConfig());
96+
}
8097
}

app/code/Magento/Checkout/Block/Cart/Sidebar.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,29 @@ class Sidebar extends AbstractCart
2727
*/
2828
protected $imageHelper;
2929

30+
/**
31+
* @var \Magento\Framework\Serialize\Serializer\Json
32+
*/
33+
private $serializer;
34+
3035
/**
3136
* @param \Magento\Framework\View\Element\Template\Context $context
3237
* @param \Magento\Customer\Model\Session $customerSession
3338
* @param \Magento\Checkout\Model\Session $checkoutSession
3439
* @param \Magento\Catalog\Helper\Image $imageHelper
3540
* @param \Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface $jsLayoutDataProvider
3641
* @param array $data
37-
* @codeCoverageIgnore
42+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
43+
* @throws \RuntimeException
3844
*/
3945
public function __construct(
4046
\Magento\Framework\View\Element\Template\Context $context,
4147
\Magento\Customer\Model\Session $customerSession,
4248
\Magento\Checkout\Model\Session $checkoutSession,
4349
\Magento\Catalog\Helper\Image $imageHelper,
4450
\Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface $jsLayoutDataProvider,
45-
array $data = []
51+
array $data = [],
52+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
4653
) {
4754
if (isset($data['jsLayout'])) {
4855
$this->jsLayout = array_merge_recursive($jsLayoutDataProvider->getData(), $data['jsLayout']);
@@ -53,6 +60,8 @@ public function __construct(
5360
parent::__construct($context, $customerSession, $checkoutSession, $data);
5461
$this->_isScopePrivate = false;
5562
$this->imageHelper = $imageHelper;
63+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
64+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
5665
}
5766

5867
/**
@@ -75,6 +84,14 @@ public function getConfig()
7584
];
7685
}
7786

87+
/**
88+
* @return string
89+
*/
90+
public function getSerializedConfig()
91+
{
92+
return $this->serializer->serialize($this->getConfig());
93+
}
94+
7895
/**
7996
* @return string
8097
*/

app/code/Magento/Checkout/Block/Onepage.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,36 @@ class Onepage extends \Magento\Framework\View\Element\Template
3636
*/
3737
protected $layoutProcessors;
3838

39+
/**
40+
* @var \Magento\Framework\Serialize\Serializer\Json
41+
*/
42+
private $serializer;
43+
3944
/**
4045
* @param \Magento\Framework\View\Element\Template\Context $context
4146
* @param \Magento\Framework\Data\Form\FormKey $formKey
4247
* @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider
4348
* @param array $layoutProcessors
4449
* @param array $data
50+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
51+
* @throws \RuntimeException
4552
*/
4653
public function __construct(
4754
\Magento\Framework\View\Element\Template\Context $context,
4855
\Magento\Framework\Data\Form\FormKey $formKey,
4956
\Magento\Checkout\Model\CompositeConfigProvider $configProvider,
5057
array $layoutProcessors = [],
51-
array $data = []
58+
array $data = [],
59+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
5260
) {
5361
parent::__construct($context, $data);
5462
$this->formKey = $formKey;
5563
$this->_isScopePrivate = true;
5664
$this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : [];
5765
$this->configProvider = $configProvider;
5866
$this->layoutProcessors = $layoutProcessors;
67+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
68+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
5969
}
6070

6171
/**
@@ -66,7 +76,7 @@ public function getJsLayout()
6676
foreach ($this->layoutProcessors as $processor) {
6777
$this->jsLayout = $processor->process($this->jsLayout);
6878
}
69-
return \Zend_Json::encode($this->jsLayout);
79+
return $this->serializer->serialize($this->jsLayout);
7080
}
7181

7282
/**
@@ -101,4 +111,12 @@ public function getBaseUrl()
101111
{
102112
return $this->_storeManager->getStore()->getBaseUrl();
103113
}
114+
115+
/**
116+
* @return bool|string
117+
*/
118+
public function getSerializedCheckoutConfig()
119+
{
120+
return $this->serializer->serialize($this->getCheckoutConfig());
121+
}
104122
}

app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
4747
*/
4848
protected $layout;
4949

50+
/**
51+
* @var \PHPUnit_Framework_MockObject_MockObject
52+
*/
53+
private $serializer;
54+
5055
protected function setUp()
5156
{
5257
$this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false);
@@ -69,14 +74,16 @@ protected function setUp()
6974

7075
$this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
7176
$this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager);
77+
$this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
7278

7379
$this->model = new \Magento\Checkout\Block\Cart\Shipping(
7480
$this->context,
7581
$this->customerSession,
7682
$this->checkoutSession,
7783
$this->configProvider,
7884
[$this->layoutProcessor],
79-
['jsLayout' => $this->layout]
85+
['jsLayout' => $this->layout],
86+
$this->serializer
8087
);
8188
}
8289

@@ -91,13 +98,18 @@ public function testGetJsLayout()
9198
{
9299
$layoutProcessed = $this->layout;
93100
$layoutProcessed['components']['thirdComponent'] = ['param' => 'value'];
101+
$jsonLayoutProcessed = json_encode($layoutProcessed);
94102

95103
$this->layoutProcessor->expects($this->once())
96104
->method('process')
97105
->with($this->layout)
98106
->willReturn($layoutProcessed);
107+
108+
$this->serializer->expects($this->once())->method('serialize')->will(
109+
$this->returnValue($jsonLayoutProcessed)
110+
);
99111
$this->assertEquals(
100-
\Zend_Json::encode($layoutProcessed),
112+
$jsonLayoutProcessed,
101113
$this->model->getJsLayout()
102114
);
103115
}
@@ -110,4 +122,15 @@ public function testGetBaseUrl()
110122
$this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
111123
$this->assertEquals($baseUrl, $this->model->getBaseUrl());
112124
}
125+
126+
public function testGetSerializedCheckoutConfig()
127+
{
128+
$checkoutConfig = ['checkout', 'config'];
129+
$this->configProvider->expects($this->once())->method('getConfig')->willReturn($checkoutConfig);
130+
$this->serializer->expects($this->once())->method('serialize')->will(
131+
$this->returnValue(json_encode($checkoutConfig))
132+
);
133+
134+
$this->assertEquals(json_encode($checkoutConfig), $this->model->getSerializedCheckoutConfig());
135+
}
113136
}

app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class SidebarTest extends \PHPUnit_Framework_TestCase
5353
*/
5454
protected $requestMock;
5555

56+
/**
57+
* @var \PHPUnit_Framework_MockObject_MockObject
58+
*/
59+
private $serializer;
60+
5661
protected function setUp()
5762
{
5863
$this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -94,12 +99,15 @@ protected function setUp()
9499
->method('getRequest')
95100
->will($this->returnValue($this->requestMock));
96101

102+
$this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
103+
97104
$this->model = $this->_objectManager->getObject(
98105
\Magento\Checkout\Block\Cart\Sidebar::class,
99106
[
100107
'context' => $contextMock,
101108
'imageHelper' => $this->imageHelper,
102-
'checkoutSession' => $this->checkoutSessionMock
109+
'checkoutSession' => $this->checkoutSessionMock,
110+
'serializer' => $this->serializer
103111
]
104112
);
105113
}

app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class OnepageTest extends \PHPUnit_Framework_TestCase
3232
*/
3333
protected $layoutProcessorMock;
3434

35+
/**
36+
* @var \PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
private $serializer;
39+
3540
protected function setUp()
3641
{
3742
$contextMock = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false);
@@ -54,11 +59,15 @@ protected function setUp()
5459
false
5560
);
5661

62+
$this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
63+
5764
$this->model = new \Magento\Checkout\Block\Onepage(
5865
$contextMock,
5966
$this->formKeyMock,
6067
$this->configProviderMock,
61-
[$this->layoutProcessorMock]
68+
[$this->layoutProcessorMock],
69+
[],
70+
$this->serializer
6271
);
6372
}
6473

@@ -94,7 +103,21 @@ public function testGetJsLayout()
94103
$processedLayout = ['layout' => ['processed' => true]];
95104
$jsonLayout = '{"layout":{"processed":true}}';
96105
$this->layoutProcessorMock->expects($this->once())->method('process')->with([])->willReturn($processedLayout);
106+
$this->serializer->expects($this->once())->method('serialize')->will(
107+
$this->returnValue(json_encode($processedLayout))
108+
);
97109

98110
$this->assertEquals($jsonLayout, $this->model->getJsLayout());
99111
}
112+
113+
public function testGetSerializedCheckoutConfig()
114+
{
115+
$checkoutConfig = ['checkout', 'config'];
116+
$this->configProviderMock->expects($this->once())->method('getConfig')->willReturn($checkoutConfig);
117+
$this->serializer->expects($this->once())->method('serialize')->will(
118+
$this->returnValue(json_encode($checkoutConfig))
119+
);
120+
121+
$this->assertEquals(json_encode($checkoutConfig), $this->model->getSerializedCheckoutConfig());
122+
}
100123
}

app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</div>
4444
<?php endif ?>
4545
<script>
46-
window.checkout = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getConfig()); ?>;
46+
window.checkout = <?php /* @escapeNotVerified */ echo $block->getSerializedConfig(); ?>;
4747
</script>
4848
<script type="text/x-magento-init">
4949
{

app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
</script>
2727
<script>
28-
window.checkoutConfig = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getCheckoutConfig()); ?>;
28+
window.checkoutConfig = <?php /* @escapeNotVerified */ echo $block->getSerializedCheckoutConfig(); ?>;
2929
window.customerData = window.checkoutConfig.customerData;
3030
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
3131
require([

app/code/Magento/Checkout/view/frontend/templates/onepage.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
</script>
2525
<script>
26-
window.checkoutConfig = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getCheckoutConfig()); ?>;
26+
window.checkoutConfig = <?php /* @escapeNotVerified */ echo $block->getSerializedCheckoutConfig(); ?>;
2727
// Create aliases for customer.js model from customer module
2828
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
2929
window.customerData = window.checkoutConfig.customerData;

0 commit comments

Comments
 (0)