Skip to content

Commit eb3bba5

Browse files
merge magento/2.3-qwerty into magento-borg/borg-qwerty-2.3
2 parents 3fae9ec + 98cf302 commit eb3bba5

File tree

17 files changed

+922
-156
lines changed

17 files changed

+922
-156
lines changed

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

Lines changed: 23 additions & 17 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::never())
48+
$context->expects($this->never())
4649
->method('getProcessor')
4750
->willReturn($processor);
4851

4952
$this->urlBuilder = $this->createMock(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,10 +79,10 @@ public function testPrepareDataSource()
7379
'items' => [
7480
[
7581
'block_id' => $blockId,
76-
'title' => $title
77-
]
78-
]
79-
]
82+
'title' => $title,
83+
],
84+
],
85+
],
8086
];
8187
$name = 'item_name';
8288
$expectedItems = [
@@ -93,34 +99,34 @@ public function testPrepareDataSource()
9399
'label' => __('Delete'),
94100
'confirm' => [
95101
'title' => __('Delete %1', $title),
96-
'message' => __('Are you sure you want to delete a %1 record?', $title)
102+
'message' => __('Are you sure you want to delete a %1 record?', $title),
97103
],
98-
'post' => true
99-
]
104+
'post' => true,
105+
],
100106
],
101-
]
107+
],
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
[
113119
[
114120
BlockActions::URL_PATH_EDIT,
115121
[
116-
'block_id' => $blockId
122+
'block_id' => $blockId,
117123
],
118124
'test/url/edit',
119125
],
120126
[
121127
BlockActions::URL_PATH_DELETE,
122128
[
123-
'block_id' => $blockId
129+
'block_id' => $blockId,
124130
],
125131
'test/url/delete',
126132
],
@@ -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/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Cms\Ui\Component\Listing\Column\PageActions;
99
use Magento\Framework\Escaper;
1010

11+
/**
12+
* Test for Magento\Cms\Ui\Component\Listing\Column\PageActions class.
13+
*/
1114
class PageActionsTest extends \PHPUnit\Framework\TestCase
1215
{
1316
public function testPrepareItemsByPageId()
@@ -68,12 +71,13 @@ public function testPrepareItemsByPageId()
6871
'label' => __('Delete'),
6972
'confirm' => [
7073
'title' => __('Delete %1', $title),
71-
'message' => __('Are you sure you want to delete a %1 record?', $title)
74+
'message' => __('Are you sure you want to delete a %1 record?', $title),
75+
'__disableTmpl' => true,
7276
],
73-
'post' => true
74-
]
77+
'post' => true,
78+
],
7579
],
76-
]
80+
],
7781
];
7882

7983
$escaper->expects(static::once())

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

Lines changed: 8 additions & 10 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
@@ -62,31 +60,31 @@ public function prepareDataSource(array $dataSource)
6260
if (isset($dataSource['data']['items'])) {
6361
foreach ($dataSource['data']['items'] as & $item) {
6462
if (isset($item['block_id'])) {
65-
$title = $this->getEscaper()->escapeHtml($item['title']);
63+
$title = $this->getEscaper()->escapeHtmlAttr($item['title']);
6664
$item[$this->getData('name')] = [
6765
'edit' => [
6866
'href' => $this->urlBuilder->getUrl(
6967
static::URL_PATH_EDIT,
7068
[
71-
'block_id' => $item['block_id']
69+
'block_id' => $item['block_id'],
7270
]
7371
),
74-
'label' => __('Edit')
72+
'label' => __('Edit'),
7573
],
7674
'delete' => [
7775
'href' => $this->urlBuilder->getUrl(
7876
static::URL_PATH_DELETE,
7977
[
80-
'block_id' => $item['block_id']
78+
'block_id' => $item['block_id'],
8179
]
8280
),
8381
'label' => __('Delete'),
8482
'confirm' => [
8583
'title' => __('Delete %1', $title),
86-
'message' => __('Are you sure you want to delete a %1 record?', $title)
84+
'message' => __('Are you sure you want to delete a %1 record?', $title),
8785
],
88-
'post' => true
89-
]
86+
'post' => true,
87+
],
9088
];
9189
}
9290
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ public function prepareDataSource(array $dataSource)
8585
'label' => __('Delete'),
8686
'confirm' => [
8787
'title' => __('Delete %1', $title),
88-
'message' => __('Are you sure you want to delete a %1 record?', $title)
88+
'message' => __('Are you sure you want to delete a %1 record?', $title),
89+
'__disableTmpl' => true,
8990
],
90-
'post' => true
91+
'post' => true,
9192
];
9293
}
9394
if (isset($item['identifier'])) {

app/code/Magento/Sales/Controller/Guest/View.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
use Magento\Sales\Helper\Guest as GuestHelper;
1010
use Magento\Framework\View\Result\PageFactory;
1111
use Magento\Framework\Controller\ResultInterface;
12+
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1213

13-
class View extends Action\Action
14+
/**
15+
* Guest order view action.
16+
*/
17+
class View extends Action\Action implements HttpPostActionInterface
1418
{
1519
/**
1620
* @var \Magento\Sales\Helper\Guest
@@ -38,7 +42,7 @@ public function __construct(
3842
}
3943

4044
/**
41-
* @return \Magento\Framework\Controller\ResultInterface
45+
* @inheritdoc
4246
*/
4347
public function execute()
4448
{

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
namespace Magento\GraphQl\Customer;
99

1010
use Magento\Customer\Api\CustomerRepositoryInterface;
11-
use Magento\Customer\Model\CustomerRegistry;
11+
use Magento\Framework\Registry;
1212
use Magento\TestFramework\Helper\Bootstrap;
1313
use Magento\TestFramework\TestCase\GraphQlAbstract;
1414

15+
/**
16+
* Test for create customer functionallity
17+
*/
1518
class CreateCustomerTest extends GraphQlAbstract
1619
{
1720
/**
18-
* @var CustomerRegistry
21+
* @var Registry
1922
*/
20-
private $customerRegistry;
23+
private $registry;
2124

2225
/**
2326
* @var CustomerRepositoryInterface
@@ -28,7 +31,7 @@ protected function setUp()
2831
{
2932
parent::setUp();
3033

31-
$this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class);
34+
$this->registry = Bootstrap::getObjectManager()->get(Registry::class);
3235
$this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
3336
}
3437

@@ -40,7 +43,7 @@ public function testCreateCustomerAccountWithPassword()
4043
$newFirstname = 'Richard';
4144
$newLastname = 'Rowe';
4245
$currentPassword = 'test123#';
43-
$newEmail = 'customer_created' . rand(1, 2000000) . '@example.com';
46+
$newEmail = 'new_customer@example.com';
4447

4548
$query = <<<QUERY
4649
mutation {
@@ -50,7 +53,7 @@ public function testCreateCustomerAccountWithPassword()
5053
lastname: "{$newLastname}"
5154
email: "{$newEmail}"
5255
password: "{$currentPassword}"
53-
is_subscribed: true
56+
is_subscribed: true
5457
}
5558
) {
5659
customer {
@@ -78,7 +81,7 @@ public function testCreateCustomerAccountWithoutPassword()
7881
{
7982
$newFirstname = 'Richard';
8083
$newLastname = 'Rowe';
81-
$newEmail = 'customer_created' . rand(1, 2000000) . '@example.com';
84+
$newEmail = 'new_customer@example.com';
8285

8386
$query = <<<QUERY
8487
mutation {
@@ -87,7 +90,7 @@ public function testCreateCustomerAccountWithoutPassword()
8790
firstname: "{$newFirstname}"
8891
lastname: "{$newLastname}"
8992
email: "{$newEmail}"
90-
is_subscribed: true
93+
is_subscribed: true
9194
}
9295
) {
9396
customer {
@@ -151,7 +154,7 @@ public function testCreateCustomerIfEmailMissed()
151154
firstname: "{$newFirstname}"
152155
lastname: "{$newLastname}"
153156
password: "{$currentPassword}"
154-
is_subscribed: true
157+
is_subscribed: true
155158
}
156159
) {
157160
customer {
@@ -186,7 +189,7 @@ public function testCreateCustomerIfEmailIsNotValid()
186189
lastname: "{$newLastname}"
187190
email: "{$newEmail}"
188191
password: "{$currentPassword}"
189-
is_subscribed: true
192+
is_subscribed: true
190193
}
191194
) {
192195
customer {
@@ -211,7 +214,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
211214
$newFirstname = 'Richard';
212215
$newLastname = 'Rowe';
213216
$currentPassword = 'test123#';
214-
$newEmail = 'customer_created' . rand(1, 2000000) . '@example.com';
217+
$newEmail = 'new_customer@example.com';
215218

216219
$query = <<<QUERY
217220
mutation {
@@ -222,7 +225,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
222225
test123: "123test123"
223226
email: "{$newEmail}"
224227
password: "{$currentPassword}"
225-
is_subscribed: true
228+
is_subscribed: true
226229
}
227230
) {
228231
customer {
@@ -237,4 +240,21 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
237240
QUERY;
238241
$this->graphQlQuery($query);
239242
}
243+
244+
public function tearDown()
245+
{
246+
$newEmail = 'new_customer@example.com';
247+
try {
248+
$customer = $this->customerRepository->get($newEmail);
249+
} catch (\Exception $exception) {
250+
return;
251+
}
252+
253+
$this->registry->unregister('isSecureArea');
254+
$this->registry->register('isSecureArea', true);
255+
$this->customerRepository->delete($customer);
256+
$this->registry->unregister('isSecureArea');
257+
$this->registry->register('isSecureArea', false);
258+
parent::tearDown();
259+
}
240260
}

0 commit comments

Comments
 (0)