Skip to content

Commit 1dd2127

Browse files
committed
AC-15051:[CE] PHPUnit 12: Upgrade Product Types related test cases
1 parent 88f5d67 commit 1dd2127

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Wishlist\Test\Unit\Helper;
9+
10+
use Magento\Wishlist\Model\Item;
11+
12+
/**
13+
* Test helper for Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
14+
* Using Magento\Wishlist\Model\Item class as We need an concrete class to implement the interface
15+
* Implements ItemInterface to provide custom methods for testing
16+
*/
17+
class ItemTestHelper extends Item
18+
{
19+
/**
20+
* @var array
21+
*/
22+
private $data = [];
23+
24+
/**
25+
* Constructor
26+
*/
27+
public function __construct()
28+
{
29+
// No parent constructor to call for interface
30+
}
31+
32+
/**
33+
* Get option by code
34+
*
35+
* @param string $code
36+
* @return mixed
37+
*/
38+
public function getOptionByCode($code)
39+
{
40+
// Support callback pattern used in Bundle tests
41+
if (isset($this->data['option_by_code_callback']) && is_callable($this->data['option_by_code_callback'])) {
42+
return call_user_func($this->data['option_by_code_callback'], $code);
43+
}
44+
45+
return $this->data['options'][$code] ?? $this->data['option_by_code_callback'] ?? null;
46+
}
47+
48+
/**
49+
* Set option by code for testing
50+
* Supports both individual options and callback patterns
51+
*
52+
* @param string|callable|null $codeOrCallback
53+
* @param mixed $option
54+
* @return self
55+
*/
56+
public function setOptionByCode($codeOrCallback, $option = null): self
57+
{
58+
// If only one parameter is provided, it's either a callback or null
59+
if (func_num_args() === 1) {
60+
$this->data['option_by_code_callback'] = $codeOrCallback;
61+
} else {
62+
// Two parameters: traditional code => option mapping
63+
$this->data['options'][$codeOrCallback] = $option;
64+
}
65+
return $this;
66+
}
67+
}

0 commit comments

Comments
 (0)