Skip to content

Commit a470039

Browse files
committed
Merge remote-tracking branch 'origin/common_phpunit_test' into phpunit10
2 parents ae8e61a + 69791d8 commit a470039

File tree

30 files changed

+143
-108
lines changed

30 files changed

+143
-108
lines changed

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ class AdvancedPricingTest extends AbstractImportTestCase
137137
* @var ProcessingErrorAggregatorInterface
138138
*/
139139
protected $errorAggregator;
140-
private MockObject|CurrencyResolver $currencyResolver;
140+
141+
/**
142+
* @var MockObject|CurrencyResolver
143+
*/
144+
private $currencyResolver;
141145

142146
/**
143147
* @inheritDoc

app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ class CryptographerTest extends TestCase
5151
* @var array
5252
*/
5353
private $initializationVectors;
54-
5554
/**
56-
* @var
55+
* @var string
5756
*/
5857
private $source;
5958

app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class RulesTest extends TestCase
3535
/**
3636
* Test constants
3737
*/
38-
const TEST_ROLE_ID = 13;
38+
public const TEST_ROLE_ID = 13;
3939

4040
/**
4141
* @var Rules

app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Backend\Block\Template\Context;
1818
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1919
use Magento\Store\Model\StoreManagerInterface;
20+
use PHPUnit\Framework\MockObject\MockObject;
2021
use PHPUnit\Framework\TestCase;
2122

2223
class SwitcherTest extends TestCase
@@ -26,6 +27,9 @@ class SwitcherTest extends TestCase
2627
*/
2728
private $switcherBlock;
2829

30+
/**
31+
* @var StoreManagerInterface|MockObject
32+
*/
2933
private $storeManagerMock;
3034

3135
/**

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ protected function setProductLinks(Product $product)
309309

310310
$linkProduct = $this->productRepository->getById($linkData['id']);
311311
$link = $this->productLinkFactory->create();
312-
echo $product->getSku();
313312
$link->setSku($product->getSku())
314313
->setLinkedProductSku($linkProduct->getSku())
315314
->setLinkType($linkType)

app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ protected function setUp(): void
9898

9999
$this->catalogMediaConfigMock = $this->createPartialMock(CatalogMediaConfig::class, ['getMediaUrlFormat']);
100100
$this->catalogMediaConfigMock->method('getMediaUrlFormat')->willReturn(CatalogMediaConfig::HASH);
101-
102-
103101
$this->helper = new Image(
104102
$this->context,
105103
$this->imageFactory,
@@ -164,7 +162,7 @@ public function testInit($data)
164162
/**
165163
* @return array
166164
*/
167-
public function initDataProvider()
165+
public static function initDataProvider()
168166
{
169167
return [
170168
[
@@ -224,7 +222,7 @@ public function testInitKeepFrame($data, $whiteBorders, $expectedKeepFrame)
224222
/**
225223
* @return array
226224
*/
227-
public function initKeepFrameDataProvider()
225+
public static function initKeepFrameDataProvider()
228226
{
229227
return [
230228
// when frame defined explicitly, it wins
@@ -439,7 +437,7 @@ public function testGetHeight($data)
439437
/**
440438
* @return array
441439
*/
442-
public function getHeightDataProvider()
440+
public static function getHeightDataProvider()
443441
{
444442
return [
445443
'data' => [
@@ -479,7 +477,7 @@ public function testGetFrame($data)
479477
/**
480478
* @return array
481479
*/
482-
public function getFrameDataProvider()
480+
public static function getFrameDataProvider()
483481
{
484482
return [
485483
'data' => [
@@ -524,7 +522,7 @@ public function testGetLabel($data, $expected)
524522
/**
525523
* @return array
526524
*/
527-
public function getLabelDataProvider()
525+
public static function getLabelDataProvider()
528526
{
529527
return [
530528
[
@@ -614,7 +612,7 @@ public function testGetResizedImageInfo(
614612
/**
615613
* @return array
616614
*/
617-
public function getResizedImageInfoDataProvider()
615+
public static function getResizedImageInfoDataProvider()
618616
{
619617
return [
620618
[

app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ConditionBuilder/FactoryTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,29 @@
1919

2020
class FactoryTest extends TestCase
2121
{
22+
/**
23+
* @var ProductResource|MockObject
24+
*/
2225
private $productResourceMock;
2326

27+
/**
28+
* @var EavConfig|MockObject
29+
*/
2430
private $eavConfigMock;
2531

32+
/**
33+
* @var CustomConditionInterface|MockObject
34+
*/
2635
private $eavAttrConditionBuilderMock;
2736

37+
/**
38+
* @var CustomConditionInterface|MockObject
39+
*/
2840
private $nativeAttrConditionBuilderMock;
2941

42+
/**
43+
* @var Factory
44+
*/
3045
private $conditionBuilderFactory;
3146

3247
protected function setUp(): void

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/StockTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class StockTest extends TestCase
2020
{
21-
const ATTRIBUTE_NAME = 'quantity_and_stock_status';
21+
public const ATTRIBUTE_NAME = 'quantity_and_stock_status';
2222

2323
/**
2424
* @var Stock

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/FlatTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
*/
2626
class FlatTest extends TestCase
2727
{
28-
const STORE_ID = 1;
29-
const TABLE_NAME = 'test_table';
30-
const PARENT_PATH = '1';
31-
const SORTED = false;
32-
const PARENT = 1;
33-
const RECURSION_LEVEL = 0;
28+
public const STORE_ID = 1;
29+
public const TABLE_NAME = 'test_table';
30+
public const PARENT_PATH = '1';
31+
public const SORTED = false;
32+
public const PARENT = 1;
33+
public const RECURSION_LEVEL = 0;
3434

3535
/**
3636
* @var CollectionFactory|MockObject

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/GalleryTest.php

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,7 @@ public function testLoadDataFromTableByValueId(): void
137137
$whereCondition = null;
138138
$getTableReturnValue = 'table';
139139
$this->connection->expects($this->once())->method('select')->willReturn($this->select);
140-
$this->select
141-
->method('from')
142-
->with(
143-
[
144-
'main' => $getTableReturnValue,
145-
],
146-
[
147-
'value_id' => 'value_id',
148-
'video_provider_default' => 'provider',
149-
'video_url_default' => 'url',
150-
'video_title_default' => 'title',
151-
'video_description_default' => 'description',
152-
'video_metadata_default' => 'metadata'
153-
]
154-
)
155-
->willReturn($this->select);
156-
$this->select
157-
->method('where')
158-
->willReturnCallback(
159-
function ($arg1, $arg2) use ($ids, $storeId) {
160-
if ($arg1 == 'main.value_id IN(?)' && $arg2 == $ids) {
161-
return $this->select;
162-
} elseif ($arg1 == 'main.store_id = ?' && $arg2 == $storeId) {
163-
return $this->select;
164-
}
165-
}
166-
);
167-
140+
$this->select = $this->seletForTableByValueId($getTableReturnValue, $ids, $storeId);
168141
$resultRow = [
169142
[
170143
'value_id' => '4',
@@ -210,6 +183,44 @@ function ($arg1, $arg2) use ($ids, $storeId) {
210183
$this->assertEquals($resultRow, $methodResult);
211184
}
212185

186+
/**
187+
* @param $getTableReturnValue
188+
* @param $ids
189+
* @param $storeId
190+
* @return Select
191+
*/
192+
protected function seletForTableByValueId($getTableReturnValue, $ids, $storeId)
193+
{
194+
$this->select
195+
->method('from')
196+
->with(
197+
[
198+
'main' => $getTableReturnValue,
199+
],
200+
[
201+
'value_id' => 'value_id',
202+
'video_provider_default' => 'provider',
203+
'video_url_default' => 'url',
204+
'video_title_default' => 'title',
205+
'video_description_default' => 'description',
206+
'video_metadata_default' => 'metadata'
207+
]
208+
)
209+
->willReturn($this->select);
210+
$this->select
211+
->method('where')
212+
->willReturnCallback(
213+
function ($arg1, $arg2) use ($ids, $storeId) {
214+
if ($arg1 == 'main.value_id IN(?)' && $arg2 == $ids) {
215+
return $this->select;
216+
} elseif ($arg1 == 'main.store_id = ?' && $arg2 == $storeId) {
217+
return $this->select;
218+
}
219+
}
220+
);
221+
return $this->select;
222+
}
223+
213224
/**
214225
* @return void
215226
*/
@@ -251,7 +262,7 @@ public function testLoadDataFromTableByValueIdNoColsWithWhere(): void
251262
$this->select
252263
->method('where')
253264
->willReturnCallback(
254-
function ($arg1, $arg2, $arg3) use ($ids, $storeId, $whereCondition) {
265+
function ($arg1, $arg2) use ($ids, $storeId, $whereCondition) {
255266
if ($arg1 == 'main.value_id IN(?)' && $arg2 == $ids) {
256267
return $this->select;
257268
} elseif ($arg1 == 'main.store_id = ?' && $arg2 == $storeId) {

0 commit comments

Comments
 (0)