Skip to content

Commit 36dbea0

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into PANDA-FIXES-2.2
2 parents 2b38033 + 9d48265 commit 36dbea0

File tree

8 files changed

+145
-56
lines changed

8 files changed

+145
-56
lines changed

app/code/Magento/Customer/Controller/Section/Load.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public function execute()
6464
{
6565
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
6666
$resultJson = $this->resultJsonFactory->create();
67-
$resultJson->setHeader('Cache-Control', 'max-age=0, must-revalidate, no-cache, no-store');
68-
$resultJson->setHeader('Pragma', 'no-cache');
67+
$resultJson->setHeader('Cache-Control', 'max-age=0, must-revalidate, no-cache, no-store', true);
68+
$resultJson->setHeader('Pragma', 'no-cache', true);
6969
try {
7070
$sectionNames = $this->getRequest()->getParam('sections');
7171
$sectionNames = $sectionNames ? array_unique(\explode(',', $sectionNames)) : null;

app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/RateQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function getBindings()
9999
}
100100
} else {
101101
$bind[':condition_name'] = $this->request->getConditionName();
102-
$bind[':condition_value'] = $this->request->getData($this->request->getConditionName());
102+
$bind[':condition_value'] = round($this->request->getData($this->request->getConditionName()), 4);
103103
}
104104

105105
return $bind;

app/code/Magento/Sales/Block/Order/Recent.php

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
*/
66
namespace Magento\Sales\Block\Order;
77

8+
use Magento\Framework\View\Element\Template\Context;
9+
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
10+
use Magento\Customer\Model\Session;
11+
use Magento\Sales\Model\Order\Config;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Framework\App\ObjectManager;
14+
815
/**
916
* Sales order history block
1017
*
@@ -13,6 +20,11 @@
1320
*/
1421
class Recent extends \Magento\Framework\View\Element\Template
1522
{
23+
/**
24+
* Limit of orders
25+
*/
26+
const ORDER_LIMIT = 5;
27+
1628
/**
1729
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
1830
*/
@@ -28,25 +40,34 @@ class Recent extends \Magento\Framework\View\Element\Template
2840
*/
2941
protected $_orderConfig;
3042

43+
/**
44+
* @var \Magento\Store\Model\StoreManagerInterface
45+
*/
46+
private $storeManager;
47+
3148
/**
3249
* @param \Magento\Framework\View\Element\Template\Context $context
3350
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
3451
* @param \Magento\Customer\Model\Session $customerSession
3552
* @param \Magento\Sales\Model\Order\Config $orderConfig
3653
* @param array $data
54+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
3755
*/
3856
public function __construct(
39-
\Magento\Framework\View\Element\Template\Context $context,
40-
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
41-
\Magento\Customer\Model\Session $customerSession,
42-
\Magento\Sales\Model\Order\Config $orderConfig,
43-
array $data = []
57+
Context $context,
58+
CollectionFactory $orderCollectionFactory,
59+
Session $customerSession,
60+
Config $orderConfig,
61+
array $data = [],
62+
StoreManagerInterface $storeManager = null
4463
) {
4564
$this->_orderCollectionFactory = $orderCollectionFactory;
4665
$this->_customerSession = $customerSession;
4766
$this->_orderConfig = $orderConfig;
48-
parent::__construct($context, $data);
4967
$this->_isScopePrivate = true;
68+
$this->storeManager = $storeManager ?: ObjectManager::getInstance()
69+
->get(StoreManagerInterface::class);
70+
parent::__construct($context, $data);
5071
}
5172

5273
/**
@@ -55,19 +76,30 @@ public function __construct(
5576
protected function _construct()
5677
{
5778
parent::_construct();
79+
$this->getRecentOrders();
80+
}
81+
82+
/**
83+
* Get recently placed orders. By default they will be limited by 5.
84+
*/
85+
protected function getRecentOrders()
86+
{
5887
$orders = $this->_orderCollectionFactory->create()->addAttributeToSelect(
5988
'*'
6089
)->addAttributeToFilter(
6190
'customer_id',
6291
$this->_customerSession->getCustomerId()
92+
)->addAttributeToFilter(
93+
'store_id',
94+
$this->storeManager->getStore()->getId()
6395
)->addAttributeToFilter(
6496
'status',
6597
['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
6698
)->addAttributeToSort(
6799
'created_at',
68100
'desc'
69101
)->setPageSize(
70-
'5'
102+
self::ORDER_LIMIT
71103
)->load();
72104
$this->setOrders($orders);
73105
}

app/code/Magento/Sales/Test/Unit/Block/Order/RecentTest.php

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
*/
66
namespace Magento\Sales\Test\Unit\Block\Order;
77

8+
use Magento\Framework\View\Element\Template\Context;
9+
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
10+
use Magento\Customer\Model\Session;
11+
use Magento\Sales\Model\Order\Config;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Framework\View\Layout;
14+
use Magento\Store\Api\Data\StoreInterface;
15+
use Magento\Sales\Model\ResourceModel\Order\Collection;
16+
817
class RecentTest extends \PHPUnit\Framework\TestCase
918
{
1019
/**
@@ -32,26 +41,33 @@ class RecentTest extends \PHPUnit\Framework\TestCase
3241
*/
3342
protected $orderConfig;
3443

44+
/**
45+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
protected $storeManagerMock;
48+
3549
protected function setUp()
3650
{
37-
$this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
51+
$this->context = $this->createMock(Context::class);
3852
$this->orderCollectionFactory = $this->createPartialMock(
39-
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class,
53+
CollectionFactory::class,
4054
['create']
4155
);
42-
$this->customerSession = $this->createPartialMock(\Magento\Customer\Model\Session::class, ['getCustomerId']);
56+
$this->customerSession = $this->createPartialMock(Session::class, ['getCustomerId']);
4357
$this->orderConfig = $this->createPartialMock(
44-
\Magento\Sales\Model\Order\Config::class,
58+
Config::class,
4559
['getVisibleOnFrontStatuses']
4660
);
61+
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
62+
->getMockForAbstractClass();
4763
}
4864

4965
public function testConstructMethod()
5066
{
51-
$data = [];
52-
$attribute = ['customer_id', 'status'];
67+
$attribute = ['customer_id', 'store_id', 'status'];
5368
$customerId = 25;
54-
$layout = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getBlock']);
69+
$storeId = 4;
70+
$layout = $this->createPartialMock(Layout::class, ['getBlock']);
5571
$this->context->expects($this->once())
5672
->method('getLayout')
5773
->will($this->returnValue($layout));
@@ -64,14 +80,20 @@ public function testConstructMethod()
6480
->method('getVisibleOnFrontStatuses')
6581
->will($this->returnValue($statuses));
6682

67-
$orderCollection = $this->createPartialMock(\Magento\Sales\Model\ResourceModel\Order\Collection::class, [
68-
'addAttributeToSelect',
69-
'addFieldToFilter',
70-
'addAttributeToFilter',
71-
'addAttributeToSort',
72-
'setPageSize',
73-
'load'
74-
]);
83+
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
84+
->getMockForAbstractClass();
85+
$storeMock = $this->getMockBuilder(StoreInterface::class)->getMockForAbstractClass();
86+
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
87+
$storeMock->expects($this->any())->method('getId')->willReturn($storeId);
88+
89+
$orderCollection = $this->createPartialMock(Collection::class, [
90+
'addAttributeToSelect',
91+
'addFieldToFilter',
92+
'addAttributeToFilter',
93+
'addAttributeToSort',
94+
'setPageSize',
95+
'load'
96+
]);
7597
$this->orderCollectionFactory->expects($this->once())
7698
->method('create')
7799
->will($this->returnValue($orderCollection));
@@ -85,25 +107,30 @@ public function testConstructMethod()
85107
->willReturnSelf();
86108
$orderCollection->expects($this->at(2))
87109
->method('addAttributeToFilter')
88-
->with($attribute[1], $this->equalTo(['in' => $statuses]))
89-
->will($this->returnSelf());
110+
->with($attribute[1], $this->equalTo($storeId))
111+
->willReturnSelf();
90112
$orderCollection->expects($this->at(3))
113+
->method('addAttributeToFilter')
114+
->with($attribute[2], $this->equalTo(['in' => $statuses]))
115+
->will($this->returnSelf());
116+
$orderCollection->expects($this->at(4))
91117
->method('addAttributeToSort')
92118
->with('created_at', 'desc')
93119
->will($this->returnSelf());
94-
$orderCollection->expects($this->at(4))
120+
$orderCollection->expects($this->at(5))
95121
->method('setPageSize')
96122
->with('5')
97123
->will($this->returnSelf());
98-
$orderCollection->expects($this->at(5))
124+
$orderCollection->expects($this->at(6))
99125
->method('load')
100126
->will($this->returnSelf());
101127
$this->block = new \Magento\Sales\Block\Order\Recent(
102128
$this->context,
103129
$this->orderCollectionFactory,
104130
$this->customerSession,
105131
$this->orderConfig,
106-
$data
132+
[],
133+
$this->storeManagerMock
107134
);
108135
$this->assertEquals($orderCollection, $this->block->getOrders());
109136
}

app/code/Magento/Sales/view/frontend/templates/order/recent.phtml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88

99
?>
1010
<div class="block block-dashboard-orders">
11-
<?php $_orders = $block->getOrders(); ?>
11+
<?php
12+
$_orders = $block->getOrders();
13+
$count = count($_orders);
14+
?>
1215
<div class="block-title order">
1316
<strong><?= /* @escapeNotVerified */ __('Recent Orders') ?></strong>
14-
<?php if (sizeof($_orders->getItems()) > 0): ?>
17+
<?php if ($count > 0): ?>
1518
<a class="action view" href="<?= /* @escapeNotVerified */ $block->getUrl('sales/order/history') ?>">
1619
<span><?= /* @escapeNotVerified */ __('View All') ?></span>
1720
</a>
1821
<?php endif; ?>
1922
</div>
2023
<div class="block-content">
2124
<?= $block->getChildHtml() ?>
22-
<?php if (sizeof($_orders->getItems()) > 0): ?>
25+
<?php if ($count > 0): ?>
2326
<div class="table-wrapper orders-recent">
2427
<table class="data table table-order-items recent" id="my-orders-table">
2528
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Recent Orders') ?></caption>

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductAttributeOptionInLayeredNavigation.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
namespace Magento\ConfigurableProduct\Test\Constraint;
88

9-
use Magento\Mtf\Fixture\FixtureFactory;
10-
use Magento\Mtf\Fixture\InjectableFixture;
9+
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
1110
use Magento\Cms\Test\Page\CmsIndex;
1211
use Magento\Mtf\Constraint\AbstractConstraint;
13-
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
14-
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
15-
use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct;
12+
use Magento\Mtf\Fixture\FixtureFactory;
13+
use Magento\Mtf\Fixture\InjectableFixture;
1614

1715
/**
1816
* Check whether OOS product attribute options for configurable product are displayed on frontend in Layered navigation.
@@ -43,25 +41,33 @@ public function processAssert(
4341
'data' => [
4442
'category_ids' => [
4543
'dataset' => null,
46-
'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]
47-
]
44+
'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0],
45+
],
4846
],
4947
]
5048
)->persist();
5149

5250
$cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
53-
$filters = $catalogCategoryView->getLayeredNavigationBlock()->getFilterContents();
5451

55-
\PHPUnit_Framework_Assert::assertFalse(
52+
$attributesData = $product->hasData('configurable_attributes_data')
53+
? $product->getConfigurableAttributesData()['attributes_data']
54+
: [];
55+
56+
$attributeData = !empty($attributesData) ? array_shift($attributesData) : [];
57+
$frontendAttributeLabel = !empty($attributeData) && isset($attributeData['frontend_label'])
58+
? $attributeData['frontend_label']
59+
: '';
60+
61+
$filters = $catalogCategoryView->getLayeredNavigationBlock()->getFilterContents($frontendAttributeLabel);
62+
63+
\PHPUnit\Framework\Assert::assertFalse(
5664
in_array(strtoupper($outOfStockOption), $filters),
5765
'Out of Stock attribute option is present in layered navigation on category page.'
5866
);
5967
}
6068

6169
/**
62-
* Return string representation of object.
63-
*
64-
* @return string
70+
* @inheritdoc
6571
*/
6672
public function toString()
6773
{

dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,22 @@ public function getFilters()
104104
/**
105105
* Get all available filters.
106106
*
107+
* @param string $attributeLabel
107108
* @return array
108109
*/
109-
public function getFilterContents()
110+
public function getFilterContents($attributeLabel)
110111
{
111-
$this->waitForElementVisible($this->loadedNarrowByList);
112-
$optionContents = $this->_rootElement->find($this->optionContent, Locator::SELECTOR_XPATH);
113-
$data =[];
112+
$data = [];
113+
114+
if (trim($attributeLabel) === '') {
115+
return $data;
116+
}
117+
118+
$link = sprintf($this->filterLink, $attributeLabel);
119+
$this->openFilterContainer($attributeLabel, $link);
120+
121+
$optionContents = $this->_rootElement->getElements($link, Locator::SELECTOR_XPATH);
122+
114123
foreach ($optionContents as $optionContent) {
115124
$data[] = trim(strtoupper($optionContent->getText()));
116125
}
@@ -128,13 +137,8 @@ public function getFilterContents()
128137
*/
129138
public function applyFilter($filter, $linkPattern)
130139
{
131-
$expandFilterButton = sprintf($this->optionTitle, $filter);
132140
$links = sprintf($this->filterLink, $filter);
133-
134-
$this->waitForElementVisible($this->loadedNarrowByList);
135-
if (!$this->_rootElement->find($links, Locator::SELECTOR_XPATH)->isVisible()) {
136-
$this->_rootElement->find($expandFilterButton, Locator::SELECTOR_XPATH)->click();
137-
}
141+
$this->openFilterContainer($filter, $links);
138142

139143
$links = $this->_rootElement->getElements($links, Locator::SELECTOR_XPATH);
140144
foreach ($links as $link) {
@@ -160,4 +164,19 @@ public function isCategoryVisible(Category $category, $qty)
160164
Locator::SELECTOR_XPATH
161165
)->isVisible();
162166
}
167+
168+
/**
169+
* @param string $filter
170+
* @param string $link
171+
* @return void
172+
*/
173+
private function openFilterContainer($filter, $link)
174+
{
175+
$expandFilterButton = sprintf($this->optionTitle, $filter);
176+
177+
$this->waitForElementVisible($this->loadedNarrowByList);
178+
if (!$this->_rootElement->find($link, Locator::SELECTOR_XPATH)->isVisible()) {
179+
$this->_rootElement->find($expandFilterButton, Locator::SELECTOR_XPATH)->click();
180+
}
181+
}
163182
}

lib/web/mage/validation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@
195195
var empty = $(element).closest('table')
196196
.find('input.required-option:visible')
197197
.filter(function (i, el) {
198-
return $.mage.isEmpty(el.value);
198+
if ($(el).is('disabled')) {
199+
return $.mage.isEmpty(el.value);
200+
}
199201
})
200202
.length;
201203

0 commit comments

Comments
 (0)