Skip to content

Commit e210f78

Browse files
author
Olga Kopylova
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-34617-build-console-framework
2 parents 51ca4d9 + c0eef7c commit e210f78

File tree

147 files changed

+2508
-901
lines changed

Some content is hidden

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

147 files changed

+2508
-901
lines changed

.htaccess

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@
170170

171171
</IfModule>
172172

173-
############################################
174-
## By default allow all access
175-
176-
Order allow,deny
177-
Allow from all
178-
179173
###########################################
180174
## Deny access to release notes to prevent disclosure of the installed Magento version
181175

.htaccess.sample

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@
167167

168168
</IfModule>
169169

170-
############################################
171-
## By default allow all access
172-
173-
Order allow,deny
174-
Allow from all
175-
176170
###########################################
177171
## Deny access to release notes to prevent disclosure of the installed Magento version
178172

app/code/Magento/Backend/Block/Menu.php

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,24 @@ protected function _renderItemCssClass($menuItem, $level)
210210
*/
211211
protected function _renderAnchor($menuItem, $level)
212212
{
213-
return '<a href="' . $menuItem->getUrl() . '" ' . $this->_renderItemAnchorTitle(
214-
$menuItem
215-
) . $this->_renderItemOnclickFunction(
216-
$menuItem
217-
) . ' class="' . $this->_renderAnchorCssClass(
218-
$menuItem,
219-
$level
220-
) . '">' . '<span>' . $this->_getAnchorLabel(
221-
$menuItem
222-
) . '</span>' . '</a>';
213+
if ($level == 1 && $menuItem->getUrl() == '#') {
214+
$output = '<strong class="submenu-group-title" role="presentation">'
215+
. '<span>' . $this->_getAnchorLabel($menuItem) . '</span>'
216+
. '</strong>';
217+
} else {
218+
$output = '<a href="' . $menuItem->getUrl() . '" ' . $this->_renderItemAnchorTitle(
219+
$menuItem
220+
) . $this->_renderItemOnclickFunction(
221+
$menuItem
222+
) . ' class="' . $this->_renderAnchorCssClass(
223+
$menuItem,
224+
$level
225+
) . '">' . '<span>' . $this->_getAnchorLabel(
226+
$menuItem
227+
) . '</span>' . '</a>';
228+
}
229+
230+
return $output;
223231
}
224232

225233
/**
@@ -397,15 +405,16 @@ protected function _columnBrake($items, $limit)
397405
* @param \Magento\Backend\Model\Menu\Item $menuItem
398406
* @param int $level
399407
* @param int $limit
408+
* @param $id int
400409
* @return string HTML code
401410
*/
402-
protected function _addSubMenu($menuItem, $level, $limit)
411+
protected function _addSubMenu($menuItem, $level, $limit, $id = null)
403412
{
404413
$output = '';
405414
if (!$menuItem->hasChildren()) {
406415
return $output;
407416
}
408-
$output .= '<div class="submenu">';
417+
$output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
409418
$colStops = null;
410419
if ($level == 0 && $limit) {
411420
$colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
@@ -426,6 +435,7 @@ protected function _addSubMenu($menuItem, $level, $limit)
426435
* @param int $limit
427436
* @param array $colBrakes
428437
* @return string HTML
438+
* @SuppressWarnings(PHPMD.NPathComplexity)
429439
*/
430440
public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
431441
{
@@ -443,18 +453,21 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
443453
$output .= '</ul></li><li class="column"><ul role="menu">';
444454
}
445455

456+
$id = $this->getJsId($menuItem->getId());
446457
$output .= '<li ' . $this->getUiId(
447458
$menuItem->getId()
448459
) . ' class="item-' . $itemClass . ' ' . $this->_renderItemCssClass(
449460
$menuItem,
450461
$level
451-
) . '" role="menu-item">' . $this->_renderAnchor(
462+
) . ($level == 0 ? '" id="' . $id . '" aria-haspopup="true' : '')
463+
. '" role="menu-item">' . $this->_renderAnchor(
452464
$menuItem,
453465
$level
454466
) . $this->_addSubMenu(
455467
$menuItem,
456468
$level,
457-
$limit
469+
$limit,
470+
$id
458471
) . '</li>';
459472
$itemPosition++;
460473
}

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ protected function _convertDate($date)
205205
\IntlDateFormatter::NONE,
206206
$adminTimeZone
207207
);
208-
$simpleRes = new \DateTime('@' . $formatter->parse($date), $adminTimeZone);
208+
$simpleRes = new \DateTime(null, $adminTimeZone);
209+
$simpleRes->setTimestamp($formatter->parse($date));
209210
$simpleRes->setTime(0, 0, 0);
210211
$simpleRes->setTimezone(new \DateTimeZone('UTC'));
211212
return $simpleRes;

app/code/Magento/Backup/Model/Backup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function load($fileName, $filePath)
152152
'extension' => $this->_helper->getExtensionByType($backupData->getType()),
153153
'display_name' => $this->_helper->nameToDisplayName($backupData->getName()),
154154
'name' => $backupData->getName(),
155-
'date_object' => new \DateTime('@' . $backupData->getTime()),
155+
'date_object' => (new \DateTime())->setTimestamp($backupData->getTime()),
156156
]
157157
);
158158

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
77

8+
use Magento\Framework\Api\SimpleDataObjectConverter;
9+
810
/**
911
* Product inventory data
1012
*/
@@ -133,7 +135,7 @@ public function getFieldValue($field)
133135
{
134136
$stockItem = $this->getStockItem();
135137
if ($stockItem->getItemId()) {
136-
$method = 'get' . \Magento\Framework\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($field);
138+
$method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($field);
137139
if (method_exists($stockItem, $method)) {
138140
return $stockItem->{$method}();
139141
}
@@ -149,7 +151,7 @@ public function getConfigFieldValue($field)
149151
{
150152
$stockItem = $this->getStockItem();
151153
if ($stockItem->getItemId()) {
152-
$method = 'getUseConfig' . \Magento\Framework\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase(
154+
$method = 'getUseConfig' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase(
153155
$field
154156
);
155157
if (method_exists($stockItem, $method)) {

app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
class Upload extends \Magento\Backend\App\Action
1212
{
1313
/**
14-
* @var \Magento\Framework\Controller\Result\JsonFactory
14+
* @var \Magento\Framework\Controller\Result\RawFactory
1515
*/
16-
protected $resultJsonFactory;
16+
protected $resultRawFactory;
1717

1818
/**
1919
* @param \Magento\Backend\App\Action\Context $context
20-
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
20+
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
2121
*/
2222
public function __construct(
2323
\Magento\Backend\App\Action\Context $context,
24-
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
24+
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory
2525
) {
2626
parent::__construct($context);
27-
$this->resultJsonFactory = $resultJsonFactory;
27+
$this->resultRawFactory = $resultRawFactory;
2828
}
2929

3030
/**
@@ -36,7 +36,7 @@ protected function _isAllowed()
3636
}
3737

3838
/**
39-
* @return \Magento\Framework\Controller\Result\Json
39+
* @return \Magento\Framework\Controller\Result\Raw
4040
*/
4141
public function execute()
4242
{
@@ -72,6 +72,10 @@ public function execute()
7272
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
7373
}
7474

75-
return $this->resultJsonFactory->create()->setData($result);
75+
/** @var \Magento\Framework\Controller\Result\Raw $response */
76+
$response = $this->resultRawFactory->create();
77+
$response->setHeader('Content-type', 'text/plain');
78+
$response->setContents(json_encode($result));
79+
return $response;
7680
}
7781
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function execute()
9090
if ($storeId) {
9191
$product->setStoreId($storeId);
9292
}
93-
$setId = $this->getRequest()->getPost('set');
93+
$setId = $this->getRequest()->getPost('set') ?: $this->getRequest()->getParam('set');
9494
if ($setId) {
9595
$product->setAttributeSetId($setId);
9696
}

app/code/Magento/Catalog/Model/Product/Option/Type/Date.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function prepareForCart()
165165
$timestamp += 60 * 60 * $value['hour'] + 60 * $value['minute'];
166166
}
167167

168-
$date = new \DateTime('@' . $timestamp);
168+
$date = (new \DateTime())->setTimestamp($timestamp);
169169
$result = $date->format('Y-m-d H:i:s');
170170

171171
// Save date in internal format to avoid locale date bugs
@@ -188,19 +188,22 @@ public function getFormattedOptionValue($optionValue)
188188
{
189189
if ($this->_formattedOptionValue === null) {
190190
if ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE) {
191-
$format = $this->_localeDate->getDateFormat(
192-
\IntlDateFormatter::MEDIUM
191+
$result = $this->_localeDate->formatDateTime(
192+
new \DateTime($optionValue),
193+
\IntlDateFormatter::MEDIUM,
194+
\IntlDateFormatter::NONE
193195
);
194-
$result = \IntlDateFormatter::formatObject(new \DateTime($optionValue), $format);
195196
} elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME) {
196-
$format = $this->_localeDate->getDateTimeFormat(
197+
$result = $this->_localeDate->formatDateTime(
198+
new \DateTime($optionValue),
199+
\IntlDateFormatter::SHORT,
197200
\IntlDateFormatter::SHORT
198201
);
199-
$result = \IntlDateFormatter::formatObject(new \DateTime($optionValue), $format);
200202
} elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME) {
201-
$result = \IntlDateFormatter::formatObject(
203+
$result = $this->_localeDate->formatDateTime(
202204
new \DateTime($optionValue),
203-
$this->is24hTimeFormat() ? 'H:i' : 'h:i a'
205+
\IntlDateFormatter::NONE,
206+
\IntlDateFormatter::SHORT
204207
);
205208
} else {
206209
$result = $optionValue;

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class ValidateTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\Produ
2828
protected $initializationHelper;
2929
/** @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */
3030
protected $productFactory;
31-
/** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */
31+
/** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */
3232
protected $resultJson;
33-
/** @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject */
33+
/** @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */
3434
protected $resultJsonFactory;
3535

3636
protected function setUp()
@@ -104,8 +104,8 @@ protected function setUp()
104104
->getMock();
105105
$this->productFactory->expects($this->any())->method('create')->willReturn($this->product);
106106

107-
$this->resultJson = $this->getMock('Magento\Framework\Controller\Result\JSON', [], [], '', false);
108-
$this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
107+
$this->resultJson = $this->getMock('Magento\Framework\Controller\Result\Json', [], [], '', false);
108+
$this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
109109
->disableOriginalConstructor()
110110
->setMethods(['create'])
111111
->getMock();
@@ -126,15 +126,21 @@ protected function setUp()
126126
);
127127
}
128128

129-
/**
130-
* @return void
131-
*/
132-
public function testAttributeSetIsObtainedFromPost()
129+
public function testAttributeSetIsObtainedFromPostByDefault()
133130
{
131+
$this->request->expects($this->any())->method('getParam')->willReturnMap([['set', null, 4]]);
134132
$this->request->expects($this->any())->method('getPost')->willReturnMap([['set', null, 9]]);
135-
136133
$this->product->expects($this->once())->method('setAttributeSetId')->with(9);
137134

138135
$this->action->execute();
139136
}
137+
138+
public function testAttributeSetIsObtainedFromGetWhenThereIsNoOneInPost()
139+
{
140+
$this->request->expects($this->any())->method('getParam')->willReturnMap([['set', null, 4]]);
141+
$this->request->expects($this->any())->method('getPost')->willReturnMap([['set', null, null]]);
142+
$this->product->expects($this->once())->method('setAttributeSetId')->with(4);
143+
144+
$this->action->execute();
145+
}
140146
}

0 commit comments

Comments
 (0)