Skip to content

Commit ea6f29c

Browse files
author
Volodymyr Klymenko
authored
Merge pull request #686 from magento-tsg/2.0-prs
[TSG] Backporting for 2.0 (prs)
2 parents d4f01eb + 8aa86ea commit ea6f29c

File tree

21 files changed

+432
-54
lines changed

21 files changed

+432
-54
lines changed

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ protected function setupOrderMock(
478478
'getCustomerEmail',
479479
'getCustomerId',
480480
'getStoreId',
481-
'getTotalDue'
481+
'getBaseTotalDue'
482482
]
483483
)->getMock();
484484

@@ -501,7 +501,7 @@ protected function setupOrderMock(
501501
->method('getStoreId')
502502
->willReturn($storeId);
503503
$orderMock->expects(static::any())
504-
->method('getTotalDue')
504+
->method('getBaseTotalDue')
505505
->willReturn(self::TOTAL_AMOUNT);
506506

507507
$this->orderRepository->expects(static::any())
@@ -1704,7 +1704,7 @@ protected function setupPaymentObjectForCapture($paymentId)
17041704
$order = $this->getMockBuilder('Magento\Sales\Api\Data\OrderInterface')
17051705
->getMockForAbstractClass();
17061706
$order->expects(static::any())
1707-
->method('getTotalDue')
1707+
->method('getBaseTotalDue')
17081708
->willReturn(self::TOTAL_AMOUNT);
17091709
$this->orderRepository->expects(static::any())
17101710
->method('get')

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Controller\Adminhtml\Category;
77

8+
use Magento\Store\Model\StoreManagerInterface;
9+
810
/**
911
* Class Save
1012
*/
@@ -25,6 +27,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
2527
*/
2628
protected $layoutFactory;
2729

30+
/**
31+
* @var StoreManagerInterface
32+
*/
33+
private $storeManager;
34+
2835
/**
2936
* Constructor
3037
*
@@ -82,6 +89,9 @@ public function execute()
8289
}
8390

8491
$storeId = $this->getRequest()->getParam('store');
92+
$store = $this->getStoreManager()->getStore($storeId);
93+
$this->getStoreManager()->setCurrentStore($store->getCode());
94+
8595
$refreshTree = false;
8696
$data = $this->getRequest()->getPostValue();
8797
if ($data) {
@@ -90,9 +100,7 @@ public function execute()
90100
$parentId = $this->getRequest()->getParam('parent');
91101
if (!$parentId) {
92102
if ($storeId) {
93-
$parentId = $this->_objectManager->get(
94-
'Magento\Store\Model\StoreManagerInterface'
95-
)->getStore(
103+
$parentId = $this->getStoreManager()->getStore(
96104
$storeId
97105
)->getRootCategoryId();
98106
} else {
@@ -211,4 +219,18 @@ public function execute()
211219
$redirectParams
212220
);
213221
}
222+
223+
/**
224+
* Get StoreManager object
225+
*
226+
* @return StoreManagerInterface
227+
*/
228+
private function getStoreManager()
229+
{
230+
if ($this->storeManager == null) {
231+
$this->storeManager = $this->_objectManager->get(StoreManagerInterface::class);
232+
}
233+
234+
return $this->storeManager;
235+
}
214236
}

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function setUp()
8787
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
8888

8989
$this->contextMock = $this->getMock(
90-
'Magento\Backend\App\Action\Context',
90+
\Magento\Backend\App\Action\Context::class,
9191
[
9292
'getTitle',
9393
'getRequest',
@@ -102,47 +102,47 @@ protected function setUp()
102102
false
103103
);
104104
$this->resultRedirectFactoryMock = $this->getMock(
105-
'Magento\Backend\Model\View\Result\RedirectFactory',
105+
\Magento\Backend\Model\View\Result\RedirectFactory::class,
106106
['create'],
107107
[],
108108
'',
109109
false
110110
);
111111
$this->resultRawFactoryMock = $this->getMock(
112-
'Magento\Framework\Controller\Result\RawFactory',
112+
\Magento\Framework\Controller\Result\RawFactory::class,
113113
[],
114114
[],
115115
'',
116116
false
117117
);
118118
$this->resultJsonFactoryMock = $this->getMock(
119-
'Magento\Framework\Controller\Result\JsonFactory',
119+
\Magento\Framework\Controller\Result\JsonFactory::class,
120120
['create'],
121121
[],
122122
'',
123123
false
124124
);
125125
$this->layoutFactoryMock = $this->getMock(
126-
'Magento\Framework\View\LayoutFactory',
126+
\Magento\Framework\View\LayoutFactory::class,
127127
['create'],
128128
[],
129129
'',
130130
false
131131
);
132132
$this->requestMock = $this->getMockForAbstractClass(
133-
'Magento\Framework\App\RequestInterface',
133+
\Magento\Framework\App\RequestInterface::class,
134134
[],
135135
'',
136136
false,
137137
true,
138138
true,
139139
['getParam', 'getPost', 'getPostValue']
140140
);
141-
$this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')
141+
$this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
142142
->disableOriginalConstructor()
143143
->getMock();
144144
$this->eventManagerMock = $this->getMockForAbstractClass(
145-
'Magento\Framework\Event\ManagerInterface',
145+
\Magento\Framework\Event\ManagerInterface::class,
146146
[],
147147
'',
148148
false,
@@ -151,13 +151,13 @@ protected function setUp()
151151
['dispatch']
152152
);
153153
$this->responseMock = $this->getMockForAbstractClass(
154-
'Magento\Framework\App\ResponseInterface',
154+
\Magento\Framework\App\ResponseInterface::class,
155155
[],
156156
'',
157157
false
158158
);
159159
$this->messageManagerMock = $this->getMockForAbstractClass(
160-
'Magento\Framework\Message\ManagerInterface',
160+
\Magento\Framework\Message\ManagerInterface::class,
161161
[],
162162
'',
163163
false,
@@ -177,7 +177,7 @@ protected function setUp()
177177
->willReturn($this->resultRedirectFactoryMock);
178178

179179
$this->save = $this->objectManager->getObject(
180-
'Magento\Catalog\Controller\Adminhtml\Category\Save',
180+
\Magento\Catalog\Controller\Adminhtml\Category\Save::class,
181181
[
182182
'context' => $this->contextMock,
183183
'resultRawFactory' => $this->resultRawFactoryMock,
@@ -212,7 +212,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
212212
* |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock
213213
*/
214214
$resultRedirectMock = $this->getMock(
215-
'Magento\Backend\Model\View\Result\Redirect',
215+
\Magento\Backend\Model\View\Result\Redirect::class,
216216
[],
217217
[],
218218
'',
@@ -223,7 +223,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
223223
* |\PHPUnit_Framework_MockObject_MockObject $blockMock
224224
*/
225225
$blockMock = $this->getMock(
226-
'Magento\Framework\View\Element\Messages',
226+
\Magento\Framework\View\Element\Messages::class,
227227
['setMessages', 'getGroupedHtml'],
228228
[],
229229
'',
@@ -234,7 +234,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
234234
* |\PHPUnit_Framework_MockObject_MockObject $categoryMock
235235
*/
236236
$categoryMock = $this->getMock(
237-
'Magento\Catalog\Model\Category',
237+
\Magento\Catalog\Model\Category::class,
238238
[
239239
'setStoreId',
240240
'load',
@@ -263,7 +263,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
263263
* |\PHPUnit_Framework_MockObject_MockObject $parentCategoryMock
264264
*/
265265
$parentCategoryMock = $this->getMock(
266-
'Magento\Catalog\Model\Category',
266+
\Magento\Catalog\Model\Category::class,
267267
[
268268
'setStoreId',
269269
'load',
@@ -287,7 +287,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
287287
* |\PHPUnit_Framework_MockObject_MockObject $sessionMock
288288
*/
289289
$sessionMock = $this->getMock(
290-
'Magento\Backend\Model\Auth\Session',
290+
\Magento\Backend\Model\Auth\Session::class,
291291
['setActiveTabId'],
292292
[],
293293
'',
@@ -298,7 +298,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
298298
* |\PHPUnit_Framework_MockObject_MockObject $registryMock
299299
*/
300300
$registryMock = $this->getMock(
301-
'Magento\Framework\Registry',
301+
\Magento\Framework\Registry::class,
302302
['register'],
303303
[],
304304
'',
@@ -309,7 +309,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
309309
* |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock
310310
*/
311311
$wysiwygConfigMock = $this->getMock(
312-
'Magento\Cms\Model\Wysiwyg\Config',
312+
\Magento\Cms\Model\Wysiwyg\Config::class,
313313
['setStoreId'],
314314
[],
315315
'',
@@ -320,20 +320,20 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
320320
* |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock
321321
*/
322322
$storeManagerMock = $this->getMockForAbstractClass(
323-
'Magento\Store\Model\StoreManagerInterface',
323+
\Magento\Store\Model\StoreManagerInterface::class,
324324
[],
325325
'',
326326
false,
327327
true,
328328
true,
329-
['getStore', 'getRootCategoryId']
329+
['getStore', 'getRootCategoryId', 'setCurrentStore']
330330
);
331331
/**
332332
* @var \Magento\Framework\View\Layout
333333
* |\PHPUnit_Framework_MockObject_MockObject $layoutMock
334334
*/
335335
$layoutMock = $this->getMockForAbstractClass(
336-
'Magento\Framework\View\Layout',
336+
\Magento\Framework\View\Layout::class,
337337
[],
338338
'',
339339
false,
@@ -346,7 +346,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
346346
* |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
347347
*/
348348
$resultJsonMock = $this->getMock(
349-
'Magento\Cms\Model\Wysiwyg\Config',
349+
\Magento\Cms\Model\Wysiwyg\Config::class,
350350
['setData'],
351351
[],
352352
'',
@@ -357,13 +357,26 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
357357
* |\PHPUnit_Framework_MockObject_MockObject $messagesMock
358358
*/
359359
$messagesMock = $this->getMock(
360-
'Magento\Framework\Message\Collection',
360+
\Magento\Framework\Message\Collection::class,
361361
[],
362362
[],
363363
'',
364364
false
365365
);
366366

367+
/**
368+
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject $storeMock
369+
*/
370+
$storeMock = $this->getMock(
371+
\Magento\Store\Model\Store::class,
372+
[
373+
'getCode',
374+
],
375+
[],
376+
'',
377+
false
378+
);
379+
367380
$this->resultRedirectFactoryMock->expects($this->once())
368381
->method('create')
369382
->will($this->returnValue($resultRedirectMock));
@@ -379,6 +392,15 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
379392
]
380393
)
381394
);
395+
396+
$storeMock->expects($this->once())
397+
->method('getCode')
398+
->will($this->returnValue('admin'));
399+
400+
$storeManagerMock->expects($this->once())
401+
->method('setCurrentStore')
402+
->with('admin');
403+
382404
$this->objectManagerMock->expects($this->atLeastOnce())
383405
->method('create')
384406
->will($this->returnValue($categoryMock));
@@ -387,10 +409,10 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
387409
->will(
388410
$this->returnValueMap(
389411
[
390-
['Magento\Backend\Model\Auth\Session', $sessionMock],
391-
['Magento\Framework\Registry', $registryMock],
392-
['Magento\Cms\Model\Wysiwyg\Config', $wysiwygConfigMock],
393-
['Magento\Store\Model\StoreManagerInterface', $storeManagerMock],
412+
[\Magento\Backend\Model\Auth\Session::class, $sessionMock],
413+
[\Magento\Framework\Registry::class, $registryMock],
414+
[\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfigMock],
415+
[\Magento\Store\Model\StoreManagerInterface::class, $storeManagerMock],
394416
]
395417
)
396418
);
@@ -441,15 +463,23 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
441463

442464
if (!$parentId) {
443465
if ($storeId) {
444-
$storeManagerMock->expects($this->once())
466+
$storeManagerMock->expects($this->exactly(2))
445467
->method('getStore')
446468
->with($storeId)
447-
->will($this->returnSelf());
469+
->willReturnOnConsecutiveCalls(
470+
$storeMock,
471+
$this->returnSelf()
472+
);
448473
$storeManagerMock->expects($this->once())
449474
->method('getRootCategoryId')
450475
->will($this->returnValue($rootCategoryId));
451476
$parentId = $rootCategoryId;
452477
}
478+
} else {
479+
$storeManagerMock->expects($this->once())
480+
->method('getStore')
481+
->with($storeId)
482+
->will($this->returnValue($storeMock));
453483
}
454484
$categoryMock->expects($this->any())
455485
->method('load')
@@ -494,7 +524,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
494524
);
495525

496526
$categoryResource = $this->getMock(
497-
'Magento\Catalog\Model\ResourceModel\Category',
527+
\Magento\Catalog\Model\ResourceModel\Category::class,
498528
[],
499529
[],
500530
'',

app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414
<!-- ko foreach: { data: currentBillingAddress().customAttributes, as: 'element' } -->
1515
<!-- ko foreach: { data: Object.keys(element), as: 'attribute' } -->
16-
<!-- ko text: element[attribute].value --><!-- /ko -->
16+
<!-- ko if: (typeof element[attribute] === "object") -->
17+
<!-- ko text: element[attribute].value --><!-- /ko -->
18+
<!-- /ko -->
19+
20+
<!-- ko if: (typeof element[attribute] === "string") -->
21+
<!-- ko text: element[attribute] --><!-- /ko -->
22+
<!-- /ko --><br/>
1723
<!-- /ko -->
1824
<!-- /ko -->
1925

app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414
<!-- ko foreach: { data: address().customAttributes, as: 'element' } -->
1515
<!-- ko foreach: { data: Object.keys(element), as: 'attribute' } -->
16-
<!-- ko text: element[attribute].value --><!-- /ko -->
16+
<!-- ko if: (typeof element[attribute] === "object") -->
17+
<!-- ko text: element[attribute].value --><!-- /ko -->
18+
<!-- /ko -->
19+
20+
<!-- ko if: (typeof element[attribute] === "string") -->
21+
<!-- ko text: element[attribute] --><!-- /ko -->
22+
<!-- /ko --><br/>
1723
<!-- /ko -->
1824
<!-- /ko -->
1925

0 commit comments

Comments
 (0)