Skip to content

Commit 2e2f297

Browse files
AC-15635: PHPUnit 12 Upgrade | Replace helper files
1 parent 5677289 commit 2e2f297

File tree

25 files changed

+571
-3358
lines changed

25 files changed

+571
-3358
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Catalog\Helper\Image;
1111
use Magento\Catalog\Model\Config\CatalogMediaConfig;
1212
use Magento\Catalog\Model\Product;
13-
use Magento\Catalog\Model\Product\Image as ProductImage;
1413
use Magento\Catalog\Model\Product\ImageFactory as ProductImageFactory;
1514
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
1615
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -129,7 +128,7 @@ protected function mockImage()
129128
->onlyMethods(['create'])
130129
->getMock();
131130

132-
$this->image = $this->getMockBuilder(ProductImage::class)
131+
$this->image = $this->getMockBuilder(\Magento\Catalog\Model\Product\Image::class)
133132
->disableOriginalConstructor()
134133
->getMock();
135134
$this->imageFactory->expects($this->any())

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

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use Magento\Catalog\Model\Product\Option;
1111

1212
/**
13-
* Test helper
13+
* Test helper for Magento\Catalog\Model\Product\Option (used in Bundle tests)
14+
*
15+
* Extends Option to add custom methods for testing both Bundle and Catalog options
1416
*/
1517
class OptionTestHelper extends Option
1618
{
@@ -129,38 +131,4 @@ public function setSelections(array $selections): self
129131
$this->data['selections'] = $selections;
130132
return $this;
131133
}
132-
133-
/**
134-
* Set ignore caching (for Block compatibility)
135-
*
136-
* @param mixed $ignoreCaching
137-
* @return $this
138-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
139-
*/
140-
public function setIgnoreCaching($ignoreCaching)
141-
{
142-
return $this;
143-
}
144-
145-
/**
146-
* Set product (for Block compatibility)
147-
*
148-
* @param mixed $product
149-
* @return $this
150-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
151-
*/
152-
public function setProduct($product)
153-
{
154-
return $this;
155-
}
156-
157-
/**
158-
* Get option values (for Block compatibility)
159-
*
160-
* @return array
161-
*/
162-
public function getOptionValues()
163-
{
164-
return [];
165-
}
166134
}

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

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use Magento\Catalog\Model\Product\Type\Price;
1111

1212
/**
13-
* Test helper
13+
* Test helper for Magento\Catalog\Model\Product\Type\Price
14+
*
15+
* Extends Price to add custom methods for testing
1416
*/
1517
class PriceTestHelper extends Price
1618
{
@@ -19,21 +21,6 @@ class PriceTestHelper extends Price
1921
*/
2022
private $data = [];
2123

22-
/**
23-
* @var mixed
24-
*/
25-
private $priceId = null;
26-
27-
/**
28-
* @var mixed
29-
*/
30-
private $price = null;
31-
32-
/**
33-
* @var mixed
34-
*/
35-
private $resource = null;
36-
3724
/**
3825
* Constructor
3926
*/
@@ -79,60 +66,4 @@ public function setTotalPrices($value): self
7966
$this->data['total_prices'] = $value;
8067
return $this;
8168
}
82-
83-
/**
84-
* Set price ID (for DataProvider compatibility)
85-
*
86-
* @param mixed $priceId
87-
* @return $this
88-
*/
89-
public function setPriceId($priceId)
90-
{
91-
$this->priceId = $priceId;
92-
return $this;
93-
}
94-
95-
/**
96-
* Get price (for DataProvider compatibility)
97-
*
98-
* @return mixed
99-
*/
100-
public function getPrice()
101-
{
102-
return $this->price;
103-
}
104-
105-
/**
106-
* Set price (for DataProvider compatibility)
107-
*
108-
* @param mixed $price
109-
* @return $this
110-
*/
111-
public function setPrice($price)
112-
{
113-
$this->price = $price;
114-
return $this;
115-
}
116-
117-
/**
118-
* Get resource (for DataProvider compatibility)
119-
*
120-
* @return mixed
121-
*/
122-
public function getResource()
123-
{
124-
return $this->resource;
125-
}
126-
127-
/**
128-
* Set resource (for DataProvider compatibility)
129-
*
130-
* @param mixed $resource
131-
* @return $this
132-
*/
133-
public function setResource($resource)
134-
{
135-
$this->resource = $resource;
136-
return $this;
137-
}
13869
}

app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\Catalog\Test\Unit\Helper\Product\Flat;
99

1010
use Magento\Catalog\Helper\Product\Flat\Indexer;
11-
use Magento\Catalog\Model\Attribute\Config as AttributeConfig;
1211
use Magento\Catalog\Model\ResourceModel\ConfigFactory;
1312
use Magento\Eav\Model\Config;
1413
use Magento\Eav\Model\Entity\AttributeFactory;
@@ -73,7 +72,7 @@ protected function setUp(): void
7372

7473
$eavConfigMock = $this->createMock(Config::class);
7574

76-
$attributeConfigMock = $this->createMock(AttributeConfig::class);
75+
$attributeConfigMock = $this->createMock(\Magento\Catalog\Model\Attribute\Config::class);
7776

7877
$resourceConfigFactoryMock = $this->createPartialMock(
7978
ConfigFactory::class,

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

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ class ProductLinkTestHelper extends Link
2121
*/
2222
private $data = [];
2323

24-
/**
25-
* @var string
26-
*/
27-
private $linkedProductId;
28-
29-
/**
30-
* @var array
31-
*/
32-
private $arrayData = [];
33-
3424
/**
3525
* Constructor
3626
*/
@@ -82,47 +72,4 @@ public function setProductCollection($collection): self
8272
$this->data['product_collection'] = $collection;
8373
return $this;
8474
}
85-
86-
/**
87-
* Get linked product ID
88-
*
89-
* @return string
90-
*/
91-
public function getLinkedProductId()
92-
{
93-
return $this->linkedProductId;
94-
}
95-
96-
/**
97-
* Set linked product ID
98-
*
99-
* @param string $id
100-
* @return void
101-
*/
102-
public function setLinkedProductId($id)
103-
{
104-
$this->linkedProductId = $id;
105-
}
106-
107-
/**
108-
* Convert to array
109-
*
110-
* @param array $keys
111-
* @return array
112-
*/
113-
public function toArray(array $keys = [])
114-
{
115-
return $this->arrayData;
116-
}
117-
118-
/**
119-
* Set array data
120-
*
121-
* @param array $data
122-
* @return void
123-
*/
124-
public function setArrayData(array $data)
125-
{
126-
$this->arrayData = $data;
127-
}
12875
}

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
namespace Magento\Catalog\Test\Unit\Helper;
99

1010
use Magento\Catalog\Helper\Product;
11-
use Magento\Catalog\Model\Product as ProductModel;
1211
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13-
use PHPUnit\Framework\Attributes\DataProvider;
1412
use PHPUnit\Framework\TestCase;
1513

1614
class ProductTest extends TestCase
@@ -36,8 +34,8 @@ protected function setUp(): void
3634
/**
3735
* @param mixed $data
3836
* @param boolean $result
37+
* @dataProvider getData
3938
*/
40-
#[DataProvider('getData')]
4139
public function testIsDataForPriceIndexerWasChanged($data, $result)
4240
{
4341
if (is_callable($data)) {
@@ -48,14 +46,20 @@ public function testIsDataForPriceIndexerWasChanged($data, $result)
4846

4947
protected function getMockForCatalogProduct($method)
5048
{
51-
if ($method != null) {
52-
$product = $this->createPartialMock(ProductModel::class, [$method]);
53-
$product->expects($this->once())
54-
->method($method)
55-
->with('attribute')
56-
->willReturn(true);
57-
} else {
58-
$product = $this->createMock(ProductModel::class);
49+
$product = $this->getMockBuilder(
50+
\Magento\Catalog\Model\Product::class
51+
)->disableOriginalConstructor()
52+
->getMock();
53+
if ($method!=null) {
54+
$product->expects(
55+
$this->once()
56+
)->method(
57+
$method
58+
)->with(
59+
'attribute'
60+
)->willReturn(
61+
true
62+
);
5963
}
6064
return $product;
6165
}

0 commit comments

Comments
 (0)