Skip to content

Commit cd62a26

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #17151: Fixed a grammatical error on the vault tooltip (by @kreativedev) - #17137: GoogleAnalytics: Added unit test for order success observer (by @rogyar) - #17129: Update template.js (by @angelomaragna) - #17114: Disable autocomplete for captcha inputs (by @denistrator) - #17097: [Backport] Magento UI - Cleanup of undefined mixins parameters and usage of "leaking" variables scope (by @mageprince) - #17098: [Backport] testGetIgnoresFirstSlash method in ObjectManagerTest has lost its purpose (dummy test) (by @mageprince) - #17099: [Backport] Fix app/code/Magento/Backend/Block/Media/Uploader.php getConfigJson() method (by @mageprince) - #17077: Remove commented code (by @mage2pratik) - #17063: Added unit test for DB model in backup module (by @rogyar) - #17027: Remove spaces around amount span. (by @likemusic) - #16959: Resolved : Mobile device style groups incorrect order (by @tejash-wagento) - #16984: Categories > Left menu > Item title space fix (by @rafaelstz) - #17006: Adjust page-main container height for sticky footer; fixes #15118 (by @denistrator) - #16988: Correct return type of methods (by @mage2pratik) - #16971: Fix misprint ('_requesetd' > '_requested') (by @likemusic) - #16952: Issue 8131 - Use Redirect Factory to Allow Error Message Display on Advanced Search (by @brobie) Fixed GitHub Issues: - #14476: Mobile device style groups incorrect order in _responsive.less (reported by @damiandawber) has been fixed in #16959 by @tejash-wagento in 2.2-develop branch Related commits: 1. 9a95c66 - #15118: Responsive Design, Footers do not snap to bottom of screen on mobile devices (reported by @gwharton) has been fixed in #17006 by @denistrator in 2.2-develop branch Related commits: 1. 33a67bc - #8131: Magento 2.1.3 - There is a bug in advanced search form regarding validation messages (reported by @DarkLanternMG) has been fixed in #16952 by @brobie in 2.2-develop branch Related commits: 1. a8ba2f3 2. 6101287 3. f5c3201
2 parents 867867a + be700c9 commit cd62a26

File tree

27 files changed

+583
-133
lines changed

27 files changed

+583
-133
lines changed

app/code/Magento/Backend/Block/Media/Uploader.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Backend\Block\Media;
77

8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\Framework\Serialize\Serializer\Json;
10+
811
/**
912
* Adminhtml media library uploader
1013
* @api
@@ -27,17 +30,25 @@ class Uploader extends \Magento\Backend\Block\Widget
2730
*/
2831
protected $_fileSizeService;
2932

33+
/**
34+
* @var Json
35+
*/
36+
private $jsonEncoder;
37+
3038
/**
3139
* @param \Magento\Backend\Block\Template\Context $context
3240
* @param \Magento\Framework\File\Size $fileSize
3341
* @param array $data
42+
* @param Json $jsonEncoder
3443
*/
3544
public function __construct(
3645
\Magento\Backend\Block\Template\Context $context,
3746
\Magento\Framework\File\Size $fileSize,
38-
array $data = []
47+
array $data = [],
48+
Json $jsonEncoder = null
3949
) {
4050
$this->_fileSizeService = $fileSize;
51+
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
4152
parent::__construct($context, $data);
4253
}
4354

@@ -107,7 +118,7 @@ public function getJsObjectName()
107118
*/
108119
public function getConfigJson()
109120
{
110-
return $this->_coreData->jsonEncode($this->getConfig()->getData());
121+
return $this->jsonEncoder->encode($this->getConfig()->getData());
111122
}
112123

113124
/**
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backup\Test\Unit\Model;
9+
10+
use Magento\Backup\Model\Db;
11+
use Magento\Backup\Model\ResourceModel\Db as DbResource;
12+
use Magento\Framework\App\ResourceConnection;
13+
use Magento\Framework\Backup\Db\BackupInterface;
14+
use Magento\Framework\DataObject;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
17+
class DbTest extends \PHPUnit\Framework\TestCase
18+
{
19+
/**
20+
* @var ObjectManager
21+
*/
22+
private $objectManager;
23+
24+
/**
25+
* @var Db
26+
*/
27+
private $dbModel;
28+
29+
/**
30+
* @var DbResource|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
private $dbResourceMock;
33+
34+
/**
35+
* @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
private $connectionResourceMock;
38+
39+
protected function setUp()
40+
{
41+
$this->dbResourceMock = $this->getMockBuilder(DbResource::class)
42+
->disableOriginalConstructor()
43+
->getMock();
44+
$this->connectionResourceMock = $this->getMockBuilder(ResourceConnection::class)
45+
->disableOriginalConstructor()
46+
->getMock();
47+
48+
$this->objectManager = new ObjectManager($this);
49+
$this->dbModel = $this->objectManager->getObject(
50+
Db::class,
51+
[
52+
'resourceDb' => $this->dbResourceMock,
53+
'resource' => $this->connectionResourceMock
54+
]
55+
);
56+
}
57+
58+
public function testGetResource()
59+
{
60+
self::assertEquals($this->dbResourceMock, $this->dbModel->getResource());
61+
}
62+
63+
public function testGetTables()
64+
{
65+
$tables = [];
66+
$this->dbResourceMock->expects($this->once())
67+
->method('getTables')
68+
->willReturn($tables);
69+
70+
self::assertEquals($tables, $this->dbModel->getTables());
71+
}
72+
73+
public function testGetTableCreateScript()
74+
{
75+
$tableName = 'some_table';
76+
$script = 'script';
77+
$this->dbResourceMock->expects($this->once())
78+
->method('getTableCreateScript')
79+
->with($tableName, false)
80+
->willReturn($script);
81+
82+
self::assertEquals($script, $this->dbModel->getTableCreateScript($tableName, false));
83+
}
84+
85+
public function testGetTableDataDump()
86+
{
87+
$tableName = 'some_table';
88+
$dump = 'dump';
89+
$this->dbResourceMock->expects($this->once())
90+
->method('getTableDataDump')
91+
->with($tableName)
92+
->willReturn($dump);
93+
94+
self::assertEquals($dump, $this->dbModel->getTableDataDump($tableName));
95+
}
96+
97+
public function testGetHeader()
98+
{
99+
$header = 'header';
100+
$this->dbResourceMock->expects($this->once())
101+
->method('getHeader')
102+
->willReturn($header);
103+
104+
self::assertEquals($header, $this->dbModel->getHeader());
105+
}
106+
107+
public function testGetFooter()
108+
{
109+
$footer = 'footer';
110+
$this->dbResourceMock->expects($this->once())
111+
->method('getFooter')
112+
->willReturn($footer);
113+
114+
self::assertEquals($footer, $this->dbModel->getFooter());
115+
}
116+
117+
public function testRenderSql()
118+
{
119+
$header = 'header';
120+
$script = 'script';
121+
$tableName = 'some_table';
122+
$tables = [$tableName, $tableName];
123+
$dump = 'dump';
124+
$footer = 'footer';
125+
126+
$this->dbResourceMock->expects($this->once())
127+
->method('getTables')
128+
->willReturn($tables);
129+
$this->dbResourceMock->expects($this->once())
130+
->method('getHeader')
131+
->willReturn($header);
132+
$this->dbResourceMock->expects($this->exactly(2))
133+
->method('getTableCreateScript')
134+
->with($tableName, true)
135+
->willReturn($script);
136+
$this->dbResourceMock->expects($this->exactly(2))
137+
->method('getTableDataDump')
138+
->with($tableName)
139+
->willReturn($dump);
140+
$this->dbResourceMock->expects($this->once())
141+
->method('getFooter')
142+
->willReturn($footer);
143+
144+
self::assertEquals(
145+
$header . $script . $dump . $script . $dump . $footer,
146+
$this->dbModel->renderSql()
147+
);
148+
}
149+
150+
public function testCreateBackup()
151+
{
152+
/** @var BackupInterface|\PHPUnit_Framework_MockObject_MockObject $backupMock */
153+
$backupMock = $this->getMockBuilder(BackupInterface::class)->getMock();
154+
/** @var DataObject $tableStatus */
155+
$tableStatus = new DataObject();
156+
157+
$tableName = 'some_table';
158+
$tables = [$tableName];
159+
$header = 'header';
160+
$footer = 'footer';
161+
$dropSql = 'drop_sql';
162+
$createSql = 'create_sql';
163+
$beforeSql = 'before_sql';
164+
$afterSql = 'after_sql';
165+
$dataSql = 'data_sql';
166+
$foreignKeysSql = 'foreign_keys';
167+
$triggersSql = 'triggers_sql';
168+
$rowsCount = 2;
169+
$dataLength = 1;
170+
171+
$this->dbResourceMock->expects($this->once())
172+
->method('beginTransaction');
173+
$this->dbResourceMock->expects($this->once())
174+
->method('commitTransaction');
175+
$this->dbResourceMock->expects($this->once())
176+
->method('getTables')
177+
->willReturn($tables);
178+
$this->dbResourceMock->expects($this->once())
179+
->method('getTableDropSql')
180+
->willReturn($dropSql);
181+
$this->dbResourceMock->expects($this->once())
182+
->method('getTableCreateSql')
183+
->with($tableName, false)
184+
->willReturn($createSql);
185+
$this->dbResourceMock->expects($this->once())
186+
->method('getTableDataBeforeSql')
187+
->with($tableName)
188+
->willReturn($beforeSql);
189+
$this->dbResourceMock->expects($this->once())
190+
->method('getTableDataAfterSql')
191+
->with($tableName)
192+
->willReturn($afterSql);
193+
$this->dbResourceMock->expects($this->once())
194+
->method('getTableDataSql')
195+
->with($tableName, $rowsCount, 0)
196+
->willReturn($dataSql);
197+
$this->dbResourceMock->expects($this->once())
198+
->method('getTableStatus')
199+
->with($tableName)
200+
->willReturn($tableStatus);
201+
$this->dbResourceMock->expects($this->once())
202+
->method('getTables')
203+
->willReturn($createSql);
204+
$this->dbResourceMock->expects($this->once())
205+
->method('getHeader')
206+
->willReturn($header);
207+
$this->dbResourceMock->expects($this->once())
208+
->method('getTableHeader')
209+
->willReturn($header);
210+
$this->dbResourceMock->expects($this->once())
211+
->method('getFooter')
212+
->willReturn($footer);
213+
$this->dbResourceMock->expects($this->once())
214+
->method('getTableForeignKeysSql')
215+
->willReturn($foreignKeysSql);
216+
$this->dbResourceMock->expects($this->once())
217+
->method('getTableTriggersSql')
218+
->willReturn($triggersSql);
219+
$backupMock->expects($this->once())
220+
->method('open');
221+
$backupMock->expects($this->once())
222+
->method('close');
223+
224+
$tableStatus->setRows($rowsCount);
225+
$tableStatus->setDataLength($dataLength);
226+
227+
$backupMock->expects($this->any())
228+
->method('write')
229+
->withConsecutive(
230+
[$this->equalTo($header)],
231+
[$this->equalTo($header . $dropSql . "\n")],
232+
[$this->equalTo($createSql . "\n")],
233+
[$this->equalTo($beforeSql)],
234+
[$this->equalTo($dataSql)],
235+
[$this->equalTo($afterSql)],
236+
[$this->equalTo($foreignKeysSql)],
237+
[$this->equalTo($triggersSql)],
238+
[$this->equalTo($footer)]
239+
);
240+
241+
$this->dbModel->createBackup($backupMock);
242+
}
243+
}

app/code/Magento/Braintree/view/frontend/web/template/payment/paypal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</span>
4646
<div class="field-tooltip-content"
4747
data-target="dropdown"
48-
translate="'We store you payment information securely on Braintree servers via SSL.'"></div>
48+
translate="'We store your payment information securely on Braintree servers via SSL.'"></div>
4949
</div>
5050
</div>
5151
<!-- /ko -->

app/code/Magento/Captcha/view/frontend/templates/default.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $captcha = $block->getCaptchaModel();
1414
<div class="field captcha required" role="<?= $block->escapeHtmlAttr($block->getFormId()) ?>">
1515
<label for="captcha_<?= $block->escapeHtmlAttr($block->getFormId()) ?>" class="label"><span><?= $block->escapeHtml(__('Please type the letters and numbers below')) ?></span></label>
1616
<div class="control captcha">
17-
<input name="<?= $block->escapeHtmlAttr(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE) ?>[<?= $block->escapeHtmlAttr($block->getFormId()) ?>]" type="text" class="input-text required-entry" data-validate="{required:true}" id="captcha_<?= $block->escapeHtmlAttr($block->getFormId()) ?>" />
17+
<input name="<?= $block->escapeHtmlAttr(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE) ?>[<?= $block->escapeHtmlAttr($block->getFormId()) ?>]" type="text" class="input-text required-entry" data-validate="{required:true}" id="captcha_<?= $block->escapeHtmlAttr($block->getFormId()) ?>" autocomplete="off"/>
1818
<div class="nested">
1919
<div class="field captcha no-label"
2020
data-captcha="<?= $block->escapeHtmlAttr($block->getFormId()) ?>"

app/code/Magento/Captcha/view/frontend/web/template/checkout/captcha.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="field captcha required" data-bind="blockLoader: getIsLoading()">
99
<label data-bind="attr: {for: 'captcha_' + formId}" class="label"><span data-bind="i18n: 'Please type the letters and numbers below'"></span></label>
1010
<div class="control captcha">
11-
<input name="captcha_string" type="text" class="input-text required-entry" data-bind="value: captchaValue(), attr: {id: 'captcha_' + formId, 'data-scope': dataScope}" />
11+
<input name="captcha_string" type="text" class="input-text required-entry" data-bind="value: captchaValue(), attr: {id: 'captcha_' + formId, 'data-scope': dataScope}" autocomplete="off"/>
1212
<input name="captcha_form_id" type="hidden" data-bind="value: formId, attr: {'data-scope': dataScope}" />
1313
<div class="nested">
1414
<div class="field captcha no-label">

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function __construct(
111111
/**
112112
* Initialize requested category object
113113
*
114-
* @return \Magento\Catalog\Model\Category
114+
* @return \Magento\Catalog\Model\Category|bool
115115
*/
116116
protected function _initCategory()
117117
{

app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
<?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
2020
data-price-amount="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>"
2121
data-price-type="<?= /* @escapeNotVerified */ $block->getPriceType() ?>"
22-
class="price-wrapper <?= /* @escapeNotVerified */ $block->getPriceWrapperCss() ?>">
23-
<?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
24-
</span>
22+
class="price-wrapper <?= /* @escapeNotVerified */ $block->getPriceWrapperCss() ?>"
23+
><?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?></span>
2524
<?php if ($block->hasAdjustmentsHtml()): ?>
2625
<?= $block->getAdjustmentsHtml() ?>
2726
<?php endif; ?>

app/code/Magento/CatalogSearch/Controller/Advanced/Result.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
namespace Magento\CatalogSearch\Controller\Advanced;
88

9-
use Magento\Catalog\Model\Layer\Resolver;
109
use Magento\CatalogSearch\Model\Advanced as ModelAdvanced;
1110
use Magento\Framework\App\Action\Context;
1211
use Magento\Framework\UrlFactory;
@@ -45,7 +44,7 @@ public function __construct(
4544
}
4645

4746
/**
48-
* @return void
47+
* @return \Magento\Framework\Controller\Result\Redirect
4948
*/
5049
public function execute()
5150
{
@@ -58,7 +57,9 @@ public function execute()
5857
$defaultUrl = $this->_urlFactory->create()
5958
->addQueryParams($this->getRequest()->getQueryValue())
6059
->getUrl('*/*/');
61-
$this->getResponse()->setRedirect($this->_redirect->error($defaultUrl));
60+
$resultRedirect = $this->resultRedirectFactory->create();
61+
$resultRedirect->setUrl($this->_redirect->error($defaultUrl));
62+
return $resultRedirect;
6263
}
6364
}
6465
}

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ private function getProductEmulator($typeId)
532532
* @param array $indexData
533533
* @param array $productData
534534
* @param int $storeId
535-
* @return string
535+
* @return array
536536
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
537537
* @since 100.0.3
538538
*/

app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function processAttributeValue($attribute, $value);
5555
*
5656
* @param array $index
5757
* @param string $separator
58-
* @return string
58+
* @return array
5959
*/
6060
public function prepareEntityIndex($index, $separator = ' ');
6161
}

0 commit comments

Comments
 (0)