Skip to content

Commit 5a225db

Browse files
author
Yu Tang
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents 1c135e4 + 31e3a05 commit 5a225db

File tree

33 files changed

+1420
-181
lines changed

33 files changed

+1420
-181
lines changed

app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public function execute()
1919
$variable = $this->_initVariable();
2020
$variable->addData($this->getRequest()->getPost('variable'));
2121
$result = $variable->validate();
22-
if ($result !== true && is_string($result)) {
23-
$this->messageManager->addError($result);
22+
if ($result instanceof \Magento\Framework\Phrase) {
23+
$this->messageManager->addError($result->getText());
2424
$layout = $this->layoutFactory->create();
2525
$layout->initMessages();
2626
$response->setError(true);
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Variable\Test\Unit\Controller\Adminhtml\System\Variable;
7+
8+
/**
9+
* Class ValidateTest
10+
*/
11+
class ValidateTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Variable\Model\Variable|\PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
protected $variableMock;
17+
18+
/**
19+
* @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
protected $layoutMock;
22+
23+
/**
24+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $requestMock;
27+
28+
/**
29+
* @var \Magento\Variable\Controller\Adminhtml\System\Variable\Validate | \PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
protected $validateMock;
32+
33+
/**
34+
* @var \Magento\Framework\Controller\Result\Json | \PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
protected $resultJsonMock;
37+
38+
/**
39+
* @var \Magento\Framework\Message\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
protected $messageManagerMock;
42+
43+
protected function setUp()
44+
{
45+
$this->validateMock = $this->getMockBuilder('Magento\Variable\Controller\Adminhtml\System\Variable\Validate')
46+
->disableOriginalConstructor()
47+
->getMock();
48+
49+
$this->variableMock = $this->getMockBuilder('Magento\Variable\Model\Variable')
50+
->disableOriginalConstructor()
51+
->getMock();
52+
$this->variableMock->expects($this->any())
53+
->method('addData')
54+
->willReturnSelf();
55+
56+
$messagesMock = $this->getMockBuilder('Magento\Framework\View\Element\Messages')
57+
->disableOriginalConstructor()
58+
->getMock();
59+
$this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')
60+
->setMethods(['initMessages', 'getMessagesBlock'])
61+
->getMockForAbstractClass();
62+
$this->layoutMock->expects($this->any())
63+
->method('getMessagesBlock')
64+
->willReturn($messagesMock);
65+
$layoutFactoryMock = $this->getMockBuilder('Magento\Framework\View\LayoutFactory')
66+
->disableOriginalConstructor()
67+
->getMock();
68+
$layoutFactoryMock->expects($this->any())->method('create')->willReturn($this->layoutMock);
69+
70+
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
71+
->disableOriginalConstructor()
72+
->setMethods(['getPost'])
73+
->getMockForAbstractClass();
74+
$responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')
75+
->setMethods(['setError', 'setHtmlMessage'])
76+
->getMockForAbstractClass();
77+
$this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface')
78+
->getMockForAbstractClass();
79+
$contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context')
80+
->disableOriginalConstructor()
81+
->getMock();
82+
$contextMock->expects($this->any())
83+
->method('getRequest')->will($this->returnValue($this->requestMock));
84+
$contextMock->expects($this->any())
85+
->method('getResponse')->will($this->returnValue($responseMock));
86+
$contextMock->expects($this->any())
87+
->method('getMessageManager')->will($this->returnValue($this->messageManagerMock));
88+
89+
$this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
90+
->disableOriginalConstructor()
91+
->getMock();
92+
$resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
93+
->disableOriginalConstructor()
94+
->getMock();
95+
$resultJsonFactoryMock->expects($this->any())->method('create')->willReturn($this->resultJsonMock);
96+
97+
$coreRegistryMock = $this->getMockBuilder('Magento\Framework\Registry')
98+
->disableOriginalConstructor()
99+
->getMock();
100+
101+
$this->validateMock = $this->getMockBuilder('Magento\Variable\Controller\Adminhtml\System\Variable\Validate')
102+
->setConstructorArgs(
103+
[
104+
$contextMock,
105+
$coreRegistryMock,
106+
$this->getMock('Magento\Backend\Model\View\Result\ForwardFactory', [], [], '', false),
107+
$resultJsonFactoryMock,
108+
$this->getMock('Magento\Framework\View\Result\PageFactory', [], [], '', false),
109+
$layoutFactoryMock,
110+
]
111+
)->setMethods(['_initVariable'])
112+
->getMock();
113+
$this->validateMock->expects($this->any())
114+
->method('_initVariable')
115+
->willReturn($this->variableMock);
116+
117+
}
118+
119+
/**
120+
* @param mixed $result
121+
* @param string[] $responseArray
122+
* @dataProvider executeDataProvider
123+
*/
124+
public function testExecute($result, $responseArray)
125+
{
126+
$getParamMap = [
127+
['variable_id', null, null],
128+
['store', 0, 0],
129+
];
130+
131+
$this->requestMock->expects($this->any())
132+
->method('getParam')->willReturnMap($getParamMap);
133+
$this->requestMock->expects($this->any())
134+
->method('getPost')->with('variable')->will($this->returnValue([]));
135+
136+
$this->variableMock->expects($this->any())
137+
->method('validate')
138+
->willReturn($result);
139+
140+
if ($result instanceof \Magento\Framework\Phrase) {
141+
$this->messageManagerMock->expects($this->once())
142+
->method('addError')
143+
->with($result->getText());
144+
$this->layoutMock->expects($this->once())
145+
->method('initMessages');
146+
}
147+
$this->resultJsonMock->expects($this->once())
148+
->method('setData')
149+
->with($responseArray);
150+
151+
$this->validateMock->execute();
152+
}
153+
154+
/**
155+
* @return array
156+
*/
157+
public function executeDataProvider()
158+
{
159+
return [
160+
[ false, ['error' => false]],
161+
[ true, ['error' => false]],
162+
[ __('Variable Code must be unique.'), ['error' => true, 'html_message' => null]],
163+
[ __('Validation has failed.'), ['error' => true, 'html_message' => null]],
164+
];
165+
}
166+
}

app/design/adminhtml/Magento/backend/web/css/styles.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// ---------------------------------------------
1313

1414
@import 'source/lib/_lib.less'; // Global lib
15+
@import (reference) 'source/_extends.less';
1516
@import 'source/_theme.less'; // Theme variables overrides
1617
@import 'source/_sources.less'; // Theme
1718

app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311

312312
.prices-tier {
313313
&:extend(.abs-reset-list all);
314-
.css(background, @sidebar-background);
314+
.css(background, @sidebar__background-color);
315315
padding: @indent__s (.75 * @indent__base);
316316
margin: @indent__s 0;
317317
.price-tier_price {

app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/module/_listings.less

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,29 @@
33
// * See COPYING.txt for license details.
44
// */
55

6-
@product-name-text-decoration: none;
7-
@product-name-text-decoration-hover: @link__hover__text-decoration;
6+
//
7+
// Variables
8+
// ---------------------------------------------
9+
10+
@product-name-link__color: @text__color;
11+
@product-name-link__color__active: @text__color;
12+
@product-name-link__color__hover: @text__color;
13+
@product-name-link__color__visited: @text__color;
814

15+
@product-name-link__text-decoration: none;
16+
@product-name-link__text-decoration__active: @link__hover__text-decoration;
17+
@product-name-link__text-decoration__hover: @link__hover__text-decoration;
18+
@product-name-link__text-decoration__visited: @link__hover__text-decoration;
19+
20+
//
921

1022
//
1123
// Common
1224
//--------------------------------------
1325

1426
& when (@media-common = true) {
1527

16-
.product-name() {
17-
font-weight: @font-weight__regular;
18-
> a {
19-
.link(
20-
@_link-color: @text__color,
21-
@_link-text-decoration: @product-name-text-decoration,
22-
@_link-color-visited: @text__color,
23-
@_link-text-decoration-visited: @product-name-text-decoration,
24-
@_link-color-hover: @text__color,
25-
@_link-text-decoration-hover: @product-name-text-decoration-hover,
26-
@_link-color-active: @text__color,
27-
@_link-text-decoration-active: @product-name-text-decoration-hover
28-
);
29-
}
30-
}
31-
32-
// Product Lists
28+
// Product Lists
3329
.products {
3430
margin: @indent__l 0;
3531
}
@@ -47,11 +43,11 @@
4743
&:extend(.abs-add-box-sizing all);
4844

4945
&-name {
50-
.product-name();
46+
&:extend(.abs-product-link all);
5147
display: block;
5248
margin: @indent__xs 0;
5349
word-break: break-all;
54-
// Non standard for webkit
50+
// Non standard for webkit
5551
word-break: break-word;
5652
-webkit-hyphens: auto;
5753
-moz-hyphens: auto;
@@ -248,8 +244,8 @@
248244
}
249245

250246
//
251-
// Mobile
252-
//--------------------------------------
247+
// Mobile
248+
// ---------------------------------------------
253249

254250
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
255251
.products-list .product {
@@ -302,8 +298,8 @@
302298
}
303299

304300
//
305-
// Desktop
306-
//--------------------------------------
301+
// Desktop
302+
// ---------------------------------------------
307303

308304
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
309305
.page-products .products-grid .product-item { width: 100%/3 }

app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/module/_toolbar.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
}
9595

9696
//
97-
// Mobile
98-
//--------------------------------------
97+
// Mobile
98+
// ---------------------------------------------
9999

100100
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
101101
.page-products .columns {

app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/_module.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
.opc-block-progress:extend(.abs-add-box-sizing all) {
285285
margin-bottom: @indent__l;
286286
> .title {
287-
.css(background, @sidebar-background);
287+
.css(background, @sidebar__background-color);
288288
.heading(h3);
289289
margin: 0;
290290
padding: 15px 15px @indent__base;
@@ -293,7 +293,7 @@
293293
}
294294
}
295295
> .content {
296-
.css(background, @sidebar-background);
296+
.css(background, @sidebar__background-color);
297297
padding: 0 15px @indent__xs;
298298
.item-content.complete {
299299
margin: 0 0 15px;

app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_cart.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Summary block
1717
&-summary {
1818
&:extend(.abs-add-box-sizing all);
19-
.css(background, @sidebar-background);
19+
.css(background, @sidebar__background-color);
2020
margin-bottom: @indent__m;
2121
padding: 1px 15px @indent__m;
2222
> .title {

app/design/frontend/Magento/blank/Magento_Cms/web/css/source/_widgets.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// * See COPYING.txt for license details.
44
// */
55

6-
@widgets-indent-bottom: @indent__base;
6+
@widgets-indent__bottom: @indent__base;
77

88
//
99
// Common
@@ -14,7 +14,7 @@
1414
.block-static-block,
1515
.block-cms-link {
1616
&.widget {
17-
.css(margin-bottom, @widgets-indent-bottom);
17+
.css(margin-bottom, @widgets-indent__bottom);
1818
.links & {
1919
margin-bottom: 0;
2020
}

app/design/frontend/Magento/blank/Magento_GiftMessage/web/css/source/_module.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
&:extend(.abs-reset-image-wrapper all);
3737
}
3838
.options-items {
39-
.css(background, @sidebar-background);
39+
.css(background, @sidebar__background-color);
4040
display: block;
4141
margin: @indent__base 0 0;
4242
padding: @indent__base;

0 commit comments

Comments
 (0)