Skip to content

Commit c15f4ff

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-98821' into 2.1.18-develop-pr68
2 parents adab7bb + bb52be2 commit c15f4ff

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1515

1616
/**
17-
* BlockActionsTest contains unit tests for \Magento\Cms\Ui\Component\Listing\Column\BlockActions class
17+
* BlockActionsTest contains unit tests for \Magento\Cms\Ui\Component\Listing\Column\BlockActions class.
1818
*/
1919
class BlockActionsTest extends \PHPUnit_Framework_TestCase
2020
{
@@ -33,6 +33,9 @@ class BlockActionsTest extends \PHPUnit_Framework_TestCase
3333
*/
3434
private $urlBuilder;
3535

36+
/**
37+
* @inheritdoc
38+
*/
3639
protected function setUp()
3740
{
3841
$objectManager = new ObjectManager($this);
@@ -42,15 +45,15 @@ protected function setUp()
4245
$processor = $this->getMockBuilder(Processor::class)
4346
->disableOriginalConstructor()
4447
->getMock();
45-
$context->expects(static::once())
48+
$context->expects($this->once())
4649
->method('getProcessor')
4750
->willReturn($processor);
4851

4952
$this->urlBuilder = $this->getMock(UrlInterface::class);
5053

5154
$this->escaper = $this->getMockBuilder(Escaper::class)
5255
->disableOriginalConstructor()
53-
->setMethods(['escapeHtml'])
56+
->setMethods(['escapeHtmlAttr'])
5457
->getMock();
5558

5659
$this->blockActions = $objectManager->getObject(BlockActions::class, [
@@ -62,7 +65,10 @@ protected function setUp()
6265
}
6366

6467
/**
68+
* Unit test for prepareDataSource method.
69+
*
6570
* @covers \Magento\Cms\Ui\Component\Listing\Column\BlockActions::prepareDataSource
71+
* @return void
6672
*/
6773
public function testPrepareDataSource()
6874
{
@@ -73,7 +79,7 @@ public function testPrepareDataSource()
7379
'items' => [
7480
[
7581
'block_id' => $blockId,
76-
'title' => $title
82+
'title' => $title,
7783
],
7884
],
7985
],
@@ -93,20 +99,20 @@ public function testPrepareDataSource()
9399
'label' => __('Delete'),
94100
'confirm' => [
95101
'title' => __('Delete %1', $title),
96-
'message' => __('Are you sure you wan\'t to delete a %1 record?', $title)
102+
'message' => __('Are you sure you want to delete a %1 record?', $title),
97103
],
98104
'post' => true,
99105
],
100106
],
101107
],
102108
];
103109

104-
$this->escaper->expects(static::once())
105-
->method('escapeHtml')
110+
$this->escaper->expects($this->once())
111+
->method('escapeHtmlAttr')
106112
->with($title)
107113
->willReturn($title);
108114

109-
$this->urlBuilder->expects(static::exactly(2))
115+
$this->urlBuilder->expects($this->exactly(2))
110116
->method('getUrl')
111117
->willReturnMap(
112118
[
@@ -130,6 +136,6 @@ public function testPrepareDataSource()
130136
$this->blockActions->setData('name', $name);
131137

132138
$actual = $this->blockActions->prepareDataSource($items);
133-
static::assertEquals($expectedItems, $actual['data']['items']);
139+
$this->assertEquals($expectedItems, $actual['data']['items']);
134140
}
135141
}

app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Framework\Escaper;
1414

1515
/**
16-
* Class BlockActions
16+
* Class to build edit and delete link for each item.
1717
*/
1818
class BlockActions extends Column
1919
{
@@ -35,8 +35,6 @@ class BlockActions extends Column
3535
private $escaper;
3636

3737
/**
38-
* Constructor
39-
*
4038
* @param ContextInterface $context
4139
* @param UiComponentFactory $uiComponentFactory
4240
* @param UrlInterface $urlBuilder
@@ -55,38 +53,35 @@ public function __construct(
5553
}
5654

5755
/**
58-
* Prepare Data Source.
59-
*
60-
* @param array $dataSource
61-
* @return array
56+
* @inheritdoc
6257
*/
6358
public function prepareDataSource(array $dataSource)
6459
{
6560
if (isset($dataSource['data']['items'])) {
6661
foreach ($dataSource['data']['items'] as & $item) {
6762
if (isset($item['block_id'])) {
68-
$title = $this->getEscaper()->escapeHtml($item['title']);
63+
$title = $this->getEscaper()->escapeHtmlAttr($item['title']);
6964
$item[$this->getData('name')] = [
7065
'edit' => [
7166
'href' => $this->urlBuilder->getUrl(
7267
static::URL_PATH_EDIT,
7368
[
74-
'block_id' => $item['block_id']
69+
'block_id' => $item['block_id'],
7570
]
7671
),
77-
'label' => __('Edit')
72+
'label' => __('Edit'),
7873
],
7974
'delete' => [
8075
'href' => $this->urlBuilder->getUrl(
8176
static::URL_PATH_DELETE,
8277
[
83-
'block_id' => $item['block_id']
78+
'block_id' => $item['block_id'],
8479
]
8580
),
8681
'label' => __('Delete'),
8782
'confirm' => [
8883
'title' => __('Delete %1', $title),
89-
'message' => __('Are you sure you wan\'t to delete a %1 record?', $title),
84+
'message' => __('Are you sure you want to delete a %1 record?', $title),
9085
],
9186
'post' => true,
9287
],

0 commit comments

Comments
 (0)