Skip to content

Commit 33d39af

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #17505: Refactor: remove some code duplication (by @arnoudhgz) - #17479: updating lib LESS docs (by @Karlasa)
2 parents 840d5b2 + ad88653 commit 33d39af

29 files changed

+224
-104
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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\Catalog\Test\Unit\Cron;
9+
10+
use Magento\Catalog\Cron\DeleteAbandonedStoreFlatTables;
11+
use Magento\Catalog\Helper\Product\Flat\Indexer;
12+
13+
/**
14+
* @covers \Magento\Catalog\Cron\DeleteAbandonedStoreFlatTables
15+
*/
16+
class DeleteAbandonedStoreFlatTablesTest extends \PHPUnit\Framework\TestCase
17+
{
18+
/**
19+
* Testable Object
20+
*
21+
* @var DeleteAbandonedStoreFlatTables
22+
*/
23+
private $deleteAbandonedStoreFlatTables;
24+
25+
/**
26+
* @var Indexer|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
private $indexerMock;
29+
30+
/**
31+
* Set Up
32+
*
33+
* @return void
34+
*/
35+
protected function setUp()
36+
{
37+
$this->indexerMock = $this->createMock(Indexer::class);
38+
$this->deleteAbandonedStoreFlatTables = new DeleteAbandonedStoreFlatTables($this->indexerMock);
39+
}
40+
41+
/**
42+
* Test execute method
43+
*
44+
* @return void
45+
*/
46+
public function testExecute()
47+
{
48+
$this->indexerMock->expects($this->once())->method('deleteAbandonedStoreFlatTables');
49+
$this->deleteAbandonedStoreFlatTables->execute();
50+
}
51+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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\Catalog\Test\Unit\Cron;
9+
10+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
11+
use Magento\Catalog\Cron\DeleteOutdatedPriceValues;
12+
use Magento\Eav\Api\AttributeRepositoryInterface as AttributeRepository;
13+
use Magento\Eav\Model\Entity\Attribute;
14+
use Magento\Eav\Model\Entity\Attribute\Backend\BackendInterface;
15+
use Magento\Framework\App\Config\MutableScopeConfigInterface as ScopeConfig;
16+
use Magento\Framework\App\ResourceConnection;
17+
use Magento\Framework\DB\Adapter\AdapterInterface;
18+
use Magento\Store\Model\Store;
19+
20+
/**
21+
* @covers \Magento\Catalog\Cron\DeleteOutdatedPriceValues
22+
*/
23+
class DeleteOutdatedPriceValuesTest extends \PHPUnit\Framework\TestCase
24+
{
25+
/**
26+
* Testable Object
27+
*
28+
* @var DeleteOutdatedPriceValues
29+
*/
30+
private $deleteOutdatedPriceValues;
31+
32+
/**
33+
* @var AttributeRepository|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
private $attributeRepositoryMock;
36+
37+
/**
38+
* @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
private $resourceConnectionMock;
41+
42+
/**
43+
* @var ScopeConfig|\PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
private $scopeConfigMock;
46+
47+
/**
48+
* @var Attribute|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
private $attributeMock;
51+
52+
/**
53+
* @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
54+
*/
55+
private $dbAdapterMock;
56+
57+
/**
58+
* @var BackendInterface|\PHPUnit_Framework_MockObject_MockObject
59+
*/
60+
private $attributeBackendMock;
61+
62+
/**
63+
* Set Up
64+
*
65+
* @return void
66+
*/
67+
protected function setUp()
68+
{
69+
$this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
70+
$this->attributeRepositoryMock = $this->createMock(AttributeRepository::class);
71+
$this->attributeMock = $this->createMock(Attribute::class);
72+
$this->scopeConfigMock = $this->createMock(ScopeConfig::class);
73+
$this->dbAdapterMock = $this->createMock(AdapterInterface::class);
74+
$this->attributeBackendMock = $this->createMock(BackendInterface::class);
75+
$this->deleteOutdatedPriceValues = new DeleteOutdatedPriceValues(
76+
$this->resourceConnectionMock,
77+
$this->attributeRepositoryMock,
78+
$this->scopeConfigMock
79+
);
80+
}
81+
82+
/**
83+
* Test execute method
84+
*
85+
* @return void
86+
*/
87+
public function testExecute()
88+
{
89+
$table = 'catalog_product_entity_decimal';
90+
$attributeId = 15;
91+
$conditions = ['first', 'second'];
92+
93+
$this->scopeConfigMock->expects($this->once())->method('getValue')->with(Store::XML_PATH_PRICE_SCOPE)
94+
->willReturn(Store::XML_PATH_PRICE_SCOPE);
95+
$this->attributeRepositoryMock->expects($this->once())->method('get')
96+
->with(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE)
97+
->willReturn($this->attributeMock);
98+
$this->attributeMock->expects($this->once())->method('getId')->willReturn($attributeId);
99+
$this->attributeMock->expects($this->once())->method('getBackend')->willReturn($this->attributeBackendMock);
100+
$this->attributeBackendMock->expects($this->once())->method('getTable')->willReturn($table);
101+
$this->resourceConnectionMock->expects($this->once())
102+
->method('getConnection')
103+
->willReturn($this->dbAdapterMock);
104+
$this->dbAdapterMock->expects($this->exactly(2))->method('quoteInto')->willReturnMap([
105+
['attribute_id = ?', $attributeId, null, null, $conditions[0]],
106+
['store_id != ?', Store::DEFAULT_STORE_ID, null, null, $conditions[1]],
107+
]);
108+
$this->dbAdapterMock->expects($this->once())->method('delete')->with($table, $conditions);
109+
$this->deleteOutdatedPriceValues->execute();
110+
}
111+
112+
/**
113+
* Test execute method
114+
* The price scope config option is not equal to global value
115+
*
116+
* @return void
117+
*/
118+
public function testExecutePriceConfigIsNotSetToGlobal()
119+
{
120+
$this->scopeConfigMock->expects($this->once())->method('getValue')->with(Store::XML_PATH_PRICE_SCOPE)
121+
->willReturn(null);
122+
$this->attributeRepositoryMock->expects($this->never())->method('get');
123+
$this->dbAdapterMock->expects($this->never())->method('delete');
124+
125+
$this->deleteOutdatedPriceValues->execute();
126+
}
127+
}

app/code/Magento/Customer/etc/acl.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
<resource id="Magento_Customer::customer" title="Customers" translate="title" sortOrder="40">
1313
<resource id="Magento_Customer::manage" title="All Customers" translate="title" sortOrder="10" />
1414
<resource id="Magento_Customer::online" title="Now Online" translate="title" sortOrder="20" />
15+
<resource id="Magento_Customer::group" title="Customer Groups" translate="title" sortOrder="30" />
1516
</resource>
1617
<resource id="Magento_Backend::stores">
1718
<resource id="Magento_Backend::stores_settings">
1819
<resource id="Magento_Config::config">
1920
<resource id="Magento_Customer::config_customer" title="Customers Section" translate="title" sortOrder="50" />
2021
</resource>
2122
</resource>
22-
<resource id="Magento_Backend::stores_other_settings">
23-
<resource id="Magento_Customer::group" title="Customer Groups" translate="title" sortOrder="10" />
24-
</resource>
25-
</resource>
23+
</resource>
2624
</resource>
2725
</resources>
2826
</acl>

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,7 @@ define([
330330
}
331331

332332
if (this.defaultPagesState[this.currentPage()]) {
333-
this.pagesChanged[this.currentPage()] =
334-
!compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems()));
335-
this.changed(_.some(this.pagesChanged));
333+
this.setChangedForCurrentPage();
336334
}
337335
},
338336

@@ -442,13 +440,9 @@ define([
442440
return initialize;
443441
}));
444442

445-
this.pagesChanged[this.currentPage()] =
446-
!compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems()));
447-
this.changed(_.some(this.pagesChanged));
443+
this.setChangedForCurrentPage();
448444
} else if (this.hasInitialPagesState[this.currentPage()]) {
449-
this.pagesChanged[this.currentPage()] =
450-
!compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems()));
451-
this.changed(_.some(this.pagesChanged));
445+
this.setChangedForCurrentPage();
452446
}
453447
},
454448

@@ -849,7 +843,8 @@ define([
849843
deleteRecord: function (index, recordId) {
850844
var recordInstance,
851845
lastRecord,
852-
recordsData;
846+
recordsData,
847+
lastRecordIndex;
853848

854849
if (this.deleteProperty) {
855850
recordsData = this.recordData();
@@ -868,12 +863,13 @@ define([
868863
this.update = true;
869864

870865
if (~~this.currentPage() === this.pages()) {
866+
lastRecordIndex = this.startIndex + this.getChildItems().length - 1;
871867
lastRecord =
872868
_.findWhere(this.elems(), {
873-
index: this.startIndex + this.getChildItems().length - 1
869+
index: lastRecordIndex
874870
}) ||
875871
_.findWhere(this.elems(), {
876-
index: (this.startIndex + this.getChildItems().length - 1).toString()
872+
index: lastRecordIndex.toString()
877873
});
878874

879875
lastRecord.destroy();
@@ -1134,6 +1130,18 @@ define([
11341130
});
11351131

11361132
this.isDifferedFromDefault(!_.isEqual(recordData, this.default));
1133+
},
1134+
1135+
/**
1136+
* Set the changed property if the current page is different
1137+
* than the default state
1138+
*
1139+
* @return void
1140+
*/
1141+
setChangedForCurrentPage: function () {
1142+
this.pagesChanged[this.currentPage()] =
1143+
!compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems()));
1144+
this.changed(_.some(this.pagesChanged));
11371145
}
11381146
});
11391147
});

lib/web/css/docs/actions-toolbar.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/web/css/docs/breadcrumbs.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/web/css/docs/buttons.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/web/css/docs/components.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/web/css/docs/docs.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/web/css/docs/dropdowns.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)