Skip to content

Commit dd1c76c

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-obsessive-owls/cms-team-1-delivery-sprint-12
2 parents d4bd43f + fe11b39 commit dd1c76c

File tree

19 files changed

+270
-35
lines changed

19 files changed

+270
-35
lines changed
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/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/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ private function getProductEmulator($typeId)
538538
* @param array $indexData
539539
* @param array $productData
540540
* @param int $storeId
541-
* @return string
541+
* @return array
542542
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
543543
* @since 100.0.3
544544
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function processAttributeValue($attribute, $value);
6161
*
6262
* @param array $index
6363
* @param string $separator
64-
* @return string
64+
* @return array
6565
*/
6666
public function prepareEntityIndex($index, $separator = ' ');
6767
}

app/code/Magento/ImportExport/view/adminhtml/templates/import/form/before.phtml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,13 @@ require([
178178
.loader('show');
179179
var form = jQuery('#edit_form')
180180
.one('invalid-form.validate', function(e){jQuery('body').loader('hide')});
181-
newActionUrl = (newActionUrl ? newActionUrl : form.attr('action')) +
182-
(form.attr('action').lastIndexOf('?') != -1 ? '&' : '?')+
183-
'form_key=' + encodeURIComponent(form.find('[name="form_key"]').val());
181+
182+
newActionUrl = (newActionUrl ? newActionUrl : form.attr('action'));
183+
if (newActionUrl.lastIndexOf('form_key') === -1) {
184+
newActionUrl = newActionUrl +
185+
(newActionUrl.lastIndexOf('?') !== -1 ? '&' : '?') +
186+
'form_key=' + encodeURIComponent(form.find('[name="form_key"]').val());
187+
}
184188

185189
form.trigger('save', [{
186190
action: newActionUrl,

app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public function testGetAccessTokenVerifierInvalid($verifier, $verifierFromToken)
629629
public function dataProviderForGetAccessTokenVerifierInvalidTest()
630630
{
631631
// Verifier is not a string
632-
return [[3, 3], ['wrong_length', 'wrong_length'], ['verifier', 'doesnt match']];
632+
return [[3, 3], ['wrong_length', 'wrong_length'], ['verifier', 'doesn\'t match']];
633633
}
634634

635635
public function testGetAccessToken()

app/code/Magento/Paypal/Block/Adminhtml/System/Config/ApiWizard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ApiWizard extends \Magento\Config\Block\System\Config\Form\Field
1313
/**
1414
* Path to block template
1515
*/
16-
const WIZARD_TEMPLATE = 'system/config/api_wizard.phtml';
16+
const WIZARD_TEMPLATE = 'Magento_Paypal::system/config/api_wizard.phtml';
1717

1818
/**
1919
* Set template to itself

app/code/Magento/Paypal/Block/Adminhtml/System/Config/BmlApiWizard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BmlApiWizard extends ApiWizard
1111
/**
1212
* Path to block template
1313
*/
14-
const WIZARD_TEMPLATE = 'system/config/bml_api_wizard.phtml';
14+
const WIZARD_TEMPLATE = 'Magento_Paypal::system/config/bml_api_wizard.phtml';
1515

1616
/**
1717
* Get the button and scripts contents

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ private function addTierPriceData(ProductCollection $productCollection)
323323
*/
324324
private function removeItemsWithAbsentProducts()
325325
{
326+
if (count($this->_productIds) === 0) {
327+
return;
328+
}
329+
326330
$productCollection = $this->_productCollectionFactory->create()->addIdFilter($this->_productIds);
327331
$existingProductsIds = $productCollection->getAllIds();
328332
$absentProductsIds = array_diff($this->_productIds, $existingProductsIds);

0 commit comments

Comments
 (0)