Skip to content

Commit c6741df

Browse files
author
Natalia Momotenko
committed
Merge remote-tracking branch 'origin/develop' into PR
2 parents eeac6b7 + 54a6742 commit c6741df

File tree

79 files changed

+2938
-1706
lines changed

Some content is hidden

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

79 files changed

+2938
-1706
lines changed

app/code/Magento/Backend/view/adminhtml/layout/adminhtml_system_design_grid_block.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<block class="Magento\Backend\Block\Widget\Grid\Column" as="package">
4242
<arguments>
4343
<argument name="header" xsi:type="string" translate="true">Design</argument>
44+
<argument name="type" xsi:type="string">options</argument>
45+
<argument name="options" xsi:type="options" model="Magento\Framework\View\Design\Theme\Label\Options"/>
4446
<argument name="width" xsi:type="string">150px</argument>
4547
<argument name="index" xsi:type="string">design</argument>
4648
</arguments>

app/code/Magento/Checkout/Model/ConfigProviderInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*/
66
namespace Magento\Checkout\Model;
77

8+
/**
9+
* Interface ConfigProviderInterface
10+
* @api
11+
*/
812
interface ConfigProviderInterface
913
{
1014

app/code/Magento/Checkout/view/frontend/web/js/view/payment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ define(
5353
stepNavigator.registerStep(
5454
'payment',
5555
null,
56-
$t('Review & Payments'),
56+
'Review & Payments',
5757
this.isVisible,
5858
_.bind(this.navigate, this),
5959
20

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ define(
8383
stepNavigator.registerStep(
8484
'shipping',
8585
'',
86-
$t('Shipping'),
86+
'Shipping',
8787
this.visible, _.bind(this.navigate, this),
8888
10
8989
);

app/code/Magento/Checkout/view/frontend/web/template/progress-bar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ul class="opc-progress-bar">
88
<!-- ko foreach: { data: steps().sort(sortItems), as: 'item' } -->
99
<li class="opc-progress-bar-item" data-bind="css: item.isVisible() ? '_active' : ($parent.isProcessed(item) ? '_complete' : '')">
10-
<span data-bind="text: item.title, click: $parent.navigateTo"></span>
10+
<span data-bind="i18n: item.title, click: $parent.navigateTo"></span>
1111
</li>
1212
<!-- /ko -->
1313
</ul>

app/code/Magento/Cms/Controller/Adminhtml/Block/Save.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
namespace Magento\Cms\Controller\Adminhtml\Block;
88

9+
use Magento\Cms\Model\Block;
10+
911
class Save extends \Magento\Cms\Controller\Adminhtml\Block
1012
{
1113
/**
@@ -21,6 +23,14 @@ public function execute()
2123
$data = $this->getRequest()->getPostValue();
2224
if ($data) {
2325
$id = $this->getRequest()->getParam('block_id');
26+
27+
if (isset($data['is_active']) && $data['is_active'] === 'true') {
28+
$data['is_active'] = Block::STATUS_ENABLED;
29+
}
30+
if (empty($data['block_id'])) {
31+
$data['block_id'] = null;
32+
}
33+
2434
$model = $this->_objectManager->create('Magento\Cms\Model\Block')->load($id);
2535
if (!$model->getId() && $id) {
2636
$this->messageManager->addError(__('This block no longer exists.'));

app/code/Magento/Cms/Model/Block.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class Block extends \Magento\Framework\Model\AbstractModel implements BlockInter
2121
*/
2222
const CACHE_TAG = 'cms_block';
2323

24+
/**#@+
25+
* Block's statuses
26+
*/
27+
const STATUS_ENABLED = 1;
28+
const STATUS_DISABLED = 0;
29+
30+
/**#@-*/
2431
/**
2532
* @var string
2633
*/
@@ -224,4 +231,14 @@ public function getStores()
224231
{
225232
return $this->hasData('stores') ? $this->getData('stores') : $this->getData('store_id');
226233
}
234+
235+
/**
236+
* Prepare block's statuses.
237+
*
238+
* @return array
239+
*/
240+
public function getAvailableStatuses()
241+
{
242+
return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')];
243+
}
227244
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Model\Block\Source;
7+
8+
use Magento\Framework\Data\OptionSourceInterface;
9+
10+
/**
11+
* Class IsActive
12+
*/
13+
class IsActive implements OptionSourceInterface
14+
{
15+
/**
16+
* @var \Magento\Cms\Model\Block
17+
*/
18+
protected $cmsBlock;
19+
20+
/**
21+
* Constructor
22+
*
23+
* @param \Magento\Cms\Model\Block $cmsBlock
24+
*/
25+
public function __construct(\Magento\Cms\Model\Block $cmsBlock)
26+
{
27+
$this->cmsBlock = $cmsBlock;
28+
}
29+
30+
/**
31+
* Get options
32+
*
33+
* @return array
34+
*/
35+
public function toOptionArray()
36+
{
37+
$availableOptions = $this->cmsBlock->getAvailableStatuses();
38+
$options = [];
39+
foreach ($availableOptions as $key => $value) {
40+
$options[] = [
41+
'label' => $value,
42+
'value' => $key,
43+
];
44+
}
45+
return $options;
46+
}
47+
}

app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ public function testSaveAction()
160160
'title' => '"><img src=y onerror=prompt(document.domain)>;',
161161
'identifier' => 'unique_title_123',
162162
'stores' => ['0'],
163-
'is_active' => '1',
163+
'is_active' => true,
164164
'content' => '"><script>alert("cookie: "+document.cookie)</script>'
165165
];
166166

167167
$filteredPostData = [
168168
'title' => '&quot;&gt;&lt;img src=y onerror=prompt(document.domain)&gt;;',
169169
'identifier' => 'unique_title_123',
170170
'stores' => ['0'],
171-
'is_active' => '1',
171+
'is_active' => true,
172172
'content' => '&quot;&gt;&lt;script&gt;alert(&quot;cookie: &quot;+document.cookie)&lt;/script&gt;'
173173
];
174174

@@ -228,7 +228,7 @@ public function testSaveActionWithoutData()
228228

229229
public function testSaveActionNoId()
230230
{
231-
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(true);
231+
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
232232
$this->requestMock->expects($this->atLeastOnce())
233233
->method('getParam')
234234
->willReturnMap(
@@ -261,7 +261,7 @@ public function testSaveActionNoId()
261261

262262
public function testSaveAndContinue()
263263
{
264-
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(true);
264+
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
265265
$this->requestMock->expects($this->atLeastOnce())
266266
->method('getParam')
267267
->willReturnMap(
@@ -308,7 +308,7 @@ public function testSaveAndContinue()
308308

309309
public function testSaveActionThrowsException()
310310
{
311-
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(true);
311+
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
312312
$this->requestMock->expects($this->atLeastOnce())
313313
->method('getParam')
314314
->willReturnMap(
@@ -345,7 +345,7 @@ public function testSaveActionThrowsException()
345345
$this->messageManagerMock->expects($this->once())
346346
->method('addError');
347347

348-
$this->sessionMock->expects($this->atLeastOnce())->method('setFormData')->with(true);
348+
$this->sessionMock->expects($this->atLeastOnce())->method('setFormData')->with(['block_id' => 1]);
349349

350350
$this->resultRedirect->expects($this->atLeastOnce())
351351
->method('setPath')
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Test\Unit\Model\Block\Source;
7+
8+
use Magento\Cms\Model\Block;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
11+
class IsActiveTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var Block|\PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
protected $cmsBlockMock;
17+
18+
/**
19+
* @var ObjectManager
20+
*/
21+
protected $objectManagerHelper;
22+
23+
/**
24+
* @var Block\Source\IsActive
25+
*/
26+
protected $object;
27+
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
protected function setUp()
32+
{
33+
$this->objectManagerHelper = new ObjectManager($this);
34+
$this->cmsBlockMock = $this->getMockBuilder('Magento\Cms\Model\Block')
35+
->disableOriginalConstructor()
36+
->setMethods(['getAvailableStatuses'])
37+
->getMock();
38+
39+
$this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), [
40+
'cmsBlock' => $this->cmsBlockMock,
41+
]);
42+
}
43+
44+
/**
45+
* @return string
46+
*/
47+
protected function getSourceClassName()
48+
{
49+
return 'Magento\Cms\Model\Block\Source\IsActive';
50+
}
51+
52+
/**
53+
* @param array $availableStatuses
54+
* @param array $expected
55+
* @return void
56+
* @dataProvider getAvailableStatusesDataProvider
57+
*/
58+
public function testToOptionArray(array $availableStatuses, array $expected)
59+
{
60+
$this->cmsBlockMock->expects($this->once())
61+
->method('getAvailableStatuses')
62+
->willReturn($availableStatuses);
63+
64+
$this->assertSame($expected, $this->object->toOptionArray());
65+
}
66+
67+
/**
68+
* @return array
69+
*/
70+
public function getAvailableStatusesDataProvider()
71+
{
72+
return [
73+
[
74+
[],
75+
[],
76+
],
77+
[
78+
['testStatus' => 'testValue'],
79+
[['label' => 'testValue', 'value' => 'testStatus']],
80+
],
81+
];
82+
}
83+
}

0 commit comments

Comments
 (0)