Skip to content

Commit a45d519

Browse files
committed
#22178: Static test fix.
1 parent 0c88939 commit a45d519

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Catalog product copier. Creates product duplicate
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -11,7 +9,11 @@
119
use Magento\Catalog\Model\Product;
1210

1311
/**
14-
* The copier creates product duplicates.
12+
* Catalog product copier.
13+
*
14+
* Creates product duplicate.
15+
*
16+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1517
*/
1618
class Copier
1719
{
@@ -120,10 +122,10 @@ private function setStoresUrl(Product $product, Product $duplicate) : void
120122
$productId = $product->getId();
121123
$productResource = $product->getResource();
122124
$defaultUrlKey = $productResource->getAttributeRawValue(
123-
$productId,
124-
'url_key',
125-
\Magento\Store\Model\Store::DEFAULT_STORE_ID
126-
);
125+
$productId,
126+
'url_key',
127+
\Magento\Store\Model\Store::DEFAULT_STORE_ID
128+
);
127129
$duplicate->setData('save_rewrites_history', false);
128130
foreach ($storeIds as $storeId) {
129131
$isDuplicateSaved = false;
@@ -139,6 +141,7 @@ private function setStoresUrl(Product $product, Product $duplicate) : void
139141
try {
140142
$duplicate->save();
141143
$isDuplicateSaved = true;
144+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
142145
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
143146
}
144147
} while (!$isDuplicateSaved);

app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
namespace Magento\Catalog\Test\Unit\Model\Product;
77

88
use Magento\Catalog\Api\Data\ProductInterface;
9-
use \Magento\Catalog\Model\Product\Copier;
109
use Magento\Catalog\Model\Product;
10+
use Magento\Catalog\Model\Product\Copier;
1111

1212
/**
13+
* Test for Magento\Catalog\Model\Product\Copier class.
14+
*
1315
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1416
*/
1517
class CopierTest extends \PHPUnit\Framework\TestCase
@@ -76,6 +78,9 @@ protected function setUp()
7678
]);
7779
}
7880

81+
/**
82+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
83+
*/
7984
public function testCopy()
8085
{
8186
$stockItem = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class)
@@ -104,27 +109,27 @@ public function testCopy()
104109
]);
105110

106111
$entityMock = $this->getMockForAbstractClass(
107-
\Magento\Eav\Model\Entity\AbstractEntity::class,
108-
[],
109-
'',
110-
false,
111-
true,
112-
true,
113-
['checkAttributeUniqueValue']
114-
);
112+
\Magento\Eav\Model\Entity\AbstractEntity::class,
113+
[],
114+
'',
115+
false,
116+
true,
117+
true,
118+
['checkAttributeUniqueValue']
119+
);
115120
$entityMock->expects($this->any())
116121
->method('checkAttributeUniqueValue')
117122
->willReturn(true);
118123

119124
$attributeMock = $this->getMockForAbstractClass(
120-
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
121-
[],
122-
'',
123-
false,
124-
true,
125-
true,
126-
['getEntity']
127-
);
125+
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
126+
[],
127+
'',
128+
false,
129+
true,
130+
true,
131+
['getEntity']
132+
);
128133
$attributeMock->expects($this->any())
129134
->method('getEntity')
130135
->willReturn($entityMock);

0 commit comments

Comments
 (0)