Skip to content

Commit e028c45

Browse files
committed
AC-15800::[CE] PHPUnit 12: Refactor Inline Anonymous Classes to Helper Classes in PR #2559 & PR#2579 | Add PHPUnit 12 test helpers
1 parent e4a14e0 commit e028c45

File tree

19 files changed

+1771
-0
lines changed

19 files changed

+1771
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Helper;
9+
10+
use Magento\Catalog\Api\Data\ProductRender\PriceInfoExtensionInterface;
11+
use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterface;
12+
use Magento\Msrp\Api\Data\ProductRender\MsrpPriceInfoInterface;
13+
14+
/**
15+
* Test helper for PriceInfoExtensionInterface
16+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
17+
*/
18+
// phpcs:ignore Magento2.PHP.LiteralNamespaces
19+
class PriceInfoExtensionInterfaceTestHelper implements PriceInfoExtensionInterface
20+
{
21+
/**
22+
* @var MsrpPriceInfoInterface|null
23+
*/
24+
private ?MsrpPriceInfoInterface $msrp = null;
25+
26+
/**
27+
* @var PriceInfoInterface|null
28+
*/
29+
private ?PriceInfoInterface $taxAdjustments = null;
30+
31+
/**
32+
* @var array|null
33+
*/
34+
private ?array $weeeAttributes = null;
35+
36+
/**
37+
* @var string|null
38+
*/
39+
private ?string $weeeAdjustment = null;
40+
41+
/**
42+
* Constructor
43+
*/
44+
public function __construct()
45+
{
46+
// Skip parent constructor to avoid dependency injection issues
47+
}
48+
49+
public function getMsrp(): ?MsrpPriceInfoInterface
50+
{
51+
return $this->msrp;
52+
}
53+
54+
public function setMsrp(MsrpPriceInfoInterface $msrp): self
55+
{
56+
$this->msrp = $msrp;
57+
return $this;
58+
}
59+
60+
public function getTaxAdjustments(): ?PriceInfoInterface
61+
{
62+
return $this->taxAdjustments;
63+
}
64+
65+
public function setTaxAdjustments(PriceInfoInterface $taxAdjustments): self
66+
{
67+
$this->taxAdjustments = $taxAdjustments;
68+
return $this;
69+
}
70+
71+
public function getWeeeAttributes()
72+
{
73+
return $this->weeeAttributes;
74+
}
75+
76+
public function setWeeeAttributes($attributes): self
77+
{
78+
$this->weeeAttributes = $attributes;
79+
return $this;
80+
}
81+
82+
public function getWeeeAdjustment()
83+
{
84+
return $this->weeeAdjustment;
85+
}
86+
87+
public function setWeeeAdjustment($adjustment): self
88+
{
89+
$this->weeeAdjustment = $adjustment;
90+
return $this;
91+
}
92+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Helper;
9+
10+
use Magento\Catalog\Api\Data\ProductExtensionInterface;
11+
12+
/**
13+
* Test helper for ProductExtensionInterface
14+
*
15+
* Since ProductExtensionInterface is a generated interface, we cannot use createMock()
16+
* or createPartialMock() for methods that don't exist in the base interface.
17+
* This helper provides a minimal implementation for testing purposes.
18+
*/
19+
class ProductExtensionInterfaceTestHelper implements ProductExtensionInterface
20+
{
21+
/** @var mixed */
22+
private $stockItem = null;
23+
/** @var mixed */
24+
private $bundleProductOptions = null;
25+
/** @var mixed */
26+
private $categoryLinks = null;
27+
/** @var mixed */
28+
private $configurableProductLinks = null;
29+
/** @var mixed */
30+
private $configurableProductOptions = null;
31+
/** @var mixed */
32+
private $discounts = null;
33+
/** @var mixed */
34+
private $downloadableProductLinks = null;
35+
/** @var mixed */
36+
private $downloadableProductSamples = null;
37+
/** @var mixed */
38+
private $websiteIds = null;
39+
40+
public function __construct()
41+
{
42+
}
43+
44+
public function getStockItem()
45+
{
46+
return $this->stockItem;
47+
}
48+
49+
public function setStockItem($stockItem)
50+
{
51+
$this->stockItem = $stockItem;
52+
return $this;
53+
}
54+
55+
public function getBundleProductOptions()
56+
{
57+
return $this->bundleProductOptions;
58+
}
59+
60+
public function setBundleProductOptions($bundleProductOptions)
61+
{
62+
$this->bundleProductOptions = $bundleProductOptions;
63+
return $this;
64+
}
65+
66+
public function getCategoryLinks()
67+
{
68+
return $this->categoryLinks;
69+
}
70+
71+
public function setCategoryLinks($categoryLinks)
72+
{
73+
$this->categoryLinks = $categoryLinks;
74+
return $this;
75+
}
76+
77+
public function getConfigurableProductLinks()
78+
{
79+
return $this->configurableProductLinks;
80+
}
81+
82+
public function setConfigurableProductLinks($configurableProductLinks)
83+
{
84+
$this->configurableProductLinks = $configurableProductLinks;
85+
return $this;
86+
}
87+
88+
public function getConfigurableProductOptions()
89+
{
90+
return $this->configurableProductOptions;
91+
}
92+
93+
public function setConfigurableProductOptions($configurableProductOptions)
94+
{
95+
$this->configurableProductOptions = $configurableProductOptions;
96+
return $this;
97+
}
98+
99+
public function getDiscounts()
100+
{
101+
return $this->discounts;
102+
}
103+
104+
public function setDiscounts($discounts)
105+
{
106+
$this->discounts = $discounts;
107+
return $this;
108+
}
109+
110+
public function getDownloadableProductLinks()
111+
{
112+
return $this->downloadableProductLinks;
113+
}
114+
115+
public function setDownloadableProductLinks($downloadableProductLinks)
116+
{
117+
$this->downloadableProductLinks = $downloadableProductLinks;
118+
return $this;
119+
}
120+
121+
public function getDownloadableProductSamples()
122+
{
123+
return $this->downloadableProductSamples;
124+
}
125+
126+
public function setDownloadableProductSamples($downloadableProductSamples)
127+
{
128+
$this->downloadableProductSamples = $downloadableProductSamples;
129+
return $this;
130+
}
131+
132+
public function getWebsiteIds()
133+
{
134+
return $this->websiteIds;
135+
}
136+
137+
public function setWebsiteIds($websiteIds)
138+
{
139+
$this->websiteIds = $websiteIds;
140+
return $this;
141+
}
142+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Helper;
9+
10+
use Magento\Catalog\Api\Data\ProductRender\ButtonInterface;
11+
use Magento\Catalog\Api\Data\ProductRenderExtensionInterface;
12+
13+
/**
14+
* Test helper class for ProductRenderExtensionInterface used across Catalog and related module tests
15+
*/
16+
class ProductRenderExtensionInterfaceTestHelper implements ProductRenderExtensionInterface
17+
{
18+
/** @var mixed */
19+
private $wishlistButton = null;
20+
/** @var mixed */
21+
private $reviewHtml = null;
22+
23+
public function __construct()
24+
{
25+
}
26+
27+
public function getWishlistButton()
28+
{
29+
return $this->wishlistButton;
30+
}
31+
32+
public function setWishlistButton(\Magento\Catalog\Api\Data\ProductRender\ButtonInterface $wishlistButton)
33+
{
34+
$this->wishlistButton = $wishlistButton;
35+
return $this;
36+
}
37+
38+
public function getReviewHtml()
39+
{
40+
return $this->reviewHtml;
41+
}
42+
43+
public function setReviewHtml($reviewHtml)
44+
{
45+
$this->reviewHtml = $reviewHtml;
46+
return $this;
47+
}
48+
}

0 commit comments

Comments
 (0)