Skip to content

Commit fb4668f

Browse files
committed
Merge remote-tracking branch 'origin/2.1-develop' into 2.1-develop-pr32
2 parents c9b7fcb + 2a8b266 commit fb4668f

File tree

43 files changed

+290
-1433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+290
-1433
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ atlassian*
2323
/lib/internal/flex/varien/.settings
2424
/node_modules
2525
/.grunt
26+
/Gruntfile.js
27+
/package.json
2628

2729
/pub/media/*.*
2830
!/pub/media/.htaccess

app/code/Magento/ConfigurableProduct/Model/Product/SaveHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ public function execute($entity, $arguments = [])
6666
$this->saveConfigurableProductAttributes($entity, $configurableOptions);
6767
}
6868

69-
$configurableLinks = (array) $extensionAttributes->getConfigurableProductLinks();
70-
$this->resourceModel->saveProducts($entity, $configurableLinks);
69+
$configurableLinks = $extensionAttributes->getConfigurableProductLinks();
70+
if ($configurableLinks !== null) {
71+
$configurableLinks = (array)$configurableLinks;
72+
$this->resourceModel->saveProducts($entity, $configurableLinks);
73+
}
7174

7275
return $entity;
7376
}

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ protected function _prepareLayout()
6060
$this->setChild('payment_info', $infoBlock);
6161
}
6262

63+
/**
64+
* Disable pager for print
65+
*
66+
* @return bool
67+
*/
68+
public function isPagerDisplayed()
69+
{
70+
return false;
71+
}
72+
6373
/**
6474
* @return string
6575
*/
@@ -69,13 +79,26 @@ public function getPaymentInfoHtml()
6979
}
7080

7181
/**
72-
* @return array|null
82+
* @return \Magento\Sales\Model\Order|null
7383
*/
7484
public function getOrder()
7585
{
7686
return $this->_coreRegistry->registry('current_order');
7787
}
7888

89+
/**
90+
* Get order items
91+
*
92+
* @return \Magento\Framework\DataObject[]
93+
*/
94+
public function getItems()
95+
{
96+
if (!$this->getOrder()) {
97+
return [];
98+
}
99+
return $this->getOrder()->getItemsCollection()->getItems();
100+
}
101+
79102
/**
80103
* @param AbstractBlock $renderer
81104
* @return $this
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\Unit\Block\Order;
7+
8+
use Magento\Sales\Model\ResourceModel\Order\Item\Collection as ItemCollection;
9+
10+
class PrintShipmentTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \PHPUnit_Framework_MockObject_MockObject
14+
*/
15+
private $contextMock;
16+
17+
/**
18+
* @var \PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $registryMock;
21+
22+
/**
23+
* @var \PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $itemCollectionMock;
26+
27+
/**
28+
* @var \Magento\Sales\Block\Order\PrintShipment
29+
*/
30+
private $block;
31+
32+
protected function setUp()
33+
{
34+
$this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
35+
->disableOriginalConstructor()
36+
->getMock();
37+
$this->registryMock = $this->getMockBuilder(\Magento\Framework\Registry::class)
38+
->disableOriginalConstructor()
39+
->getMock();
40+
41+
$paymentHelperMock = $this->getMockBuilder(\Magento\Payment\Helper\Data::class)
42+
->disableOriginalConstructor()
43+
->getMock();
44+
45+
$addressRendererMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Address\Renderer::class)
46+
->disableOriginalConstructor()
47+
->getMock();
48+
49+
$this->block = new \Magento\Sales\Block\Order\PrintShipment(
50+
$this->contextMock,
51+
$this->registryMock,
52+
$paymentHelperMock,
53+
$addressRendererMock
54+
);
55+
56+
$this->itemCollectionMock = $this->getMockBuilder(ItemCollection::class)
57+
->disableOriginalConstructor()
58+
->getMock();
59+
}
60+
61+
public function testIsPagerDisplayed()
62+
{
63+
$this->assertFalse($this->block->isPagerDisplayed());
64+
}
65+
66+
public function testGetItemsNoOrder()
67+
{
68+
$this->registryMock->expects($this->once())
69+
->method('registry')
70+
->with('current_order')
71+
->willReturn(null);
72+
$this->assertEmpty($this->block->getItems());
73+
}
74+
75+
public function testGetItemsSuccessful()
76+
{
77+
$orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class)
78+
->disableOriginalConstructor()
79+
->getMock();
80+
$items = [5, 3, 1];
81+
82+
$this->registryMock->expects($this->exactly(2))
83+
->method('registry')
84+
->with('current_order')
85+
->willReturn($orderMock);
86+
$orderMock->expects($this->once())
87+
->method('getItemsCollection')
88+
->willReturn($this->itemCollectionMock);
89+
$this->itemCollectionMock->expects($this->once())
90+
->method('getItems')
91+
->willReturn($items);
92+
93+
$this->assertEquals($items, $this->block->getItems());
94+
}
95+
}

app/code/Magento/Theme/Model/Design/Config/Validator.php

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,8 @@ public function validate(DesignConfigInterface $designConfig)
6464
}
6565

6666
foreach ($elements as $name => $data) {
67-
// Load template object by configured template id
68-
$template = $this->templateFactory->create();
69-
$template->emulateDesign($designConfig->getScopeId());
7067
$templateId = $data['value'];
71-
if (is_numeric($templateId)) {
72-
$template->load($templateId);
73-
} else {
74-
$template->loadDefault($templateId);
75-
}
76-
$text = $template->getTemplateText();
77-
$template->revertDesign();
68+
$text = $this->getTemplateText($templateId, $designConfig);
7869
// Check if template body has a reference to the same config path
7970
if (preg_match_all(Template::CONSTRUCTION_TEMPLATE_PATTERN, $text, $constructions, PREG_SET_ORDER)) {
8071
foreach ($constructions as $construction) {
@@ -94,6 +85,42 @@ public function validate(DesignConfigInterface $designConfig)
9485
}
9586
}
9687

88+
/**
89+
* Returns store identifier if is store scope
90+
*
91+
* @param DesignConfigInterface $designConfig
92+
* @return string|bool
93+
*/
94+
private function getScopeId(DesignConfigInterface $designConfig)
95+
{
96+
if ($designConfig->getScope() == 'stores') {
97+
return $designConfig->getScopeId();
98+
}
99+
return false;
100+
}
101+
102+
/**
103+
* Load template text in configured scope
104+
*
105+
* @param integer|string $templateId
106+
* @param DesignConfigInterface $designConfig
107+
* @return string
108+
*/
109+
private function getTemplateText($templateId, DesignConfigInterface $designConfig)
110+
{
111+
// Load template object by configured template id
112+
$template = $this->templateFactory->create();
113+
$template->emulateDesign($this->getScopeId($designConfig));
114+
if (is_numeric($templateId)) {
115+
$template->load($templateId);
116+
} else {
117+
$template->loadDefault($templateId);
118+
}
119+
$text = $template->getTemplateText();
120+
$template->revertDesign();
121+
return $text;
122+
}
123+
97124
/**
98125
* Return associative array of parameters.
99126
*

app/code/Magento/Ui/view/base/web/js/form/element/abstract.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,20 @@ define([
158158
* @returns {Abstract} Chainable.
159159
*/
160160
_setClasses: function () {
161-
var additional = this.additionalClasses,
162-
classes;
161+
var additional = this.additionalClasses;
163162

164-
if (_.isString(additional) && additional.trim().length) {
165-
additional = this.additionalClasses.trim().split(' ');
166-
classes = this.additionalClasses = {};
163+
if (_.isString(additional)){
164+
this.additionalClasses = {};
167165

168-
additional.forEach(function (name) {
169-
classes[name] = true;
170-
}, this);
166+
if (additional.trim().length) {
167+
additional = additional.trim().split(' ');
168+
169+
additional.forEach(function (name) {
170+
if (name.length) {
171+
this.additionalClasses[name] = true;
172+
}
173+
}, this);
174+
}
171175
}
172176

173177
_.extend(this.additionalClasses, {

app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ define([
161161
defaultPlaceholder: $t('Select...'),
162162
lotPlaceholders: $t('Selected')
163163
},
164-
hoverElIndex: null,
165164
separator: 'optgroup',
166165
listens: {
167166
listVisible: 'cleanHoveredElement',
@@ -295,7 +294,6 @@ define([
295294
this._super();
296295
this.observe([
297296
'listVisible',
298-
'hoverElIndex',
299297
'placeholder',
300298
'multiselectFocus',
301299
'options',
@@ -539,7 +537,7 @@ define([
539537
},
540538

541539
/**
542-
* Clean hoverElIndex variable
540+
* Clean hoveredElement variable
543541
*
544542
* @returns {Object} Chainable
545543
*/

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/View.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ class View extends Block
2020
*
2121
* @var string
2222
*/
23-
protected $recentlyViewedProducts = './/*[contains(@class,"widget")]//strong[@class="product-item-name"]';
23+
protected $recentlyViewedProducts =
24+
'.//*[contains(@class,"block-viewed-products-grid")]//strong[@class="product-item-name"]';
25+
26+
/**
27+
* New Products selectors.
28+
*
29+
* @var string
30+
*/
31+
protected $newProducts = './/*[contains(@class,"block-new-products")]//strong[@class="product-item-name"]';
2432

2533
/**
2634
* Description CSS selector.
@@ -72,4 +80,20 @@ public function getProductsFromRecentlyViewedBlock()
7280
}
7381
return $products;
7482
}
83+
84+
/**
85+
* Get products from Catalog New Products List block.
86+
*
87+
* @return array
88+
*/
89+
public function getProductsFromCatalogNewProductsListBlock()
90+
{
91+
$products = [];
92+
$this->waitForElementVisible($this->newProducts, Locator::SELECTOR_XPATH);
93+
$productNames = $this->_rootElement->getElements($this->newProducts, Locator::SELECTOR_XPATH);
94+
foreach ($productNames as $productName) {
95+
$products[] = $productName->getText();
96+
}
97+
return $products;
98+
}
7599
}

dev/tests/js/jasmine/assets/text/external.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* See COPYING.txt for license details.
55
*/
66
-->
7-
<span>External Template</span>
7+
<span>External Template</span>

dev/tests/js/jasmine/spec_runner/tasks/jasmine.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ function init(config) {
3737
host: host,
3838
template: render(files.template),
3939
vendor: files.requireJs,
40+
junit: {
41+
path: "var/log/js-unit/",
42+
consolidate: true
43+
},
4044

4145
/**
4246
* @todo rename "helpers" to "specs" (implies overriding grunt-contrib-jasmine code)

0 commit comments

Comments
 (0)