Skip to content

Commit fe2e334

Browse files
AC-15182: PHPUnit 12 Upgrade | Refactoring helper classes
1 parent 76ff762 commit fe2e334

File tree

6 files changed

+570
-0
lines changed

6 files changed

+570
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Test\Unit\Helper;
9+
10+
use Magento\Backend\Block\Widget\Grid\Column;
11+
12+
/**
13+
* Test helper for Column (Grid Column)
14+
*
15+
* This helper extends the concrete Column class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class ColumnTestHelper extends Column
19+
{
20+
/**
21+
* @var string
22+
*/
23+
private $index = 'result_data';
24+
25+
/**
26+
* Constructor that skips parent initialization
27+
*/
28+
public function __construct()
29+
{
30+
// Skip parent constructor to avoid dependency injection issues
31+
}
32+
33+
/**
34+
* Get index
35+
*
36+
* @return string
37+
*/
38+
public function getIndex()
39+
{
40+
return $this->index;
41+
}
42+
43+
/**
44+
* Set index
45+
*
46+
* @param string $index
47+
* @return $this
48+
*/
49+
public function setIndex($index)
50+
{
51+
$this->index = $index;
52+
return $this;
53+
}
54+
}
55+
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Test\Unit\Helper;
9+
10+
use Magento\Backend\Block\Widget\Grid\Column\Extended;
11+
12+
/**
13+
* Test helper for Extended (Grid Column)
14+
*
15+
* This helper extends the concrete Extended class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class ExtendedTestHelper extends Extended
19+
{
20+
/**
21+
* @var array
22+
*/
23+
private $values = [];
24+
25+
/**
26+
* @var string
27+
*/
28+
private $index = 'result_data';
29+
30+
/**
31+
* @var string
32+
*/
33+
private $htmlName = 'test';
34+
35+
/**
36+
* Constructor that skips parent initialization
37+
*/
38+
public function __construct()
39+
{
40+
// Skip parent constructor to avoid dependency injection issues
41+
}
42+
43+
/**
44+
* Get values
45+
*
46+
* @return array
47+
*/
48+
public function getValues()
49+
{
50+
return $this->values;
51+
}
52+
53+
/**
54+
* Set values
55+
*
56+
* @param array $values
57+
* @return $this
58+
*/
59+
public function setValues($values)
60+
{
61+
$this->values = $values;
62+
return $this;
63+
}
64+
65+
/**
66+
* Get index
67+
*
68+
* @return string
69+
*/
70+
public function getIndex()
71+
{
72+
return $this->index;
73+
}
74+
75+
/**
76+
* Set index
77+
*
78+
* @param string $index
79+
* @return $this
80+
*/
81+
public function setIndex($index)
82+
{
83+
$this->index = $index;
84+
return $this;
85+
}
86+
87+
/**
88+
* Get HTML name
89+
*
90+
* @return string
91+
*/
92+
public function getHtmlName()
93+
{
94+
return $this->htmlName;
95+
}
96+
97+
/**
98+
* Set HTML name
99+
*
100+
* @param string $name
101+
* @return $this
102+
*/
103+
public function setHtmlName($name)
104+
{
105+
$this->htmlName = $name;
106+
return $this;
107+
}
108+
}
109+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Helper;
9+
10+
use Magento\Catalog\Model\Product;
11+
12+
/**
13+
* Test helper for ProductInterface
14+
*
15+
* This helper extends the concrete Product class to provide
16+
* test-specific functionality without dependency injection issues.
17+
* Extends existing implementation instead of implementing interface from scratch.
18+
*/
19+
class ProductInterfaceTestHelper extends Product
20+
{
21+
/**
22+
* @var bool
23+
*/
24+
private $isObjectNew = true;
25+
26+
/**
27+
* @var string|null
28+
*/
29+
private $typeId = null;
30+
31+
/**
32+
* Constructor that skips parent initialization
33+
*/
34+
public function __construct()
35+
{
36+
// Skip parent constructor to avoid dependency injection issues
37+
}
38+
39+
/**
40+
* Check if object is new
41+
*
42+
* @param bool|null $flag
43+
* @return bool
44+
*/
45+
public function isObjectNew($flag = null)
46+
{
47+
return $this->isObjectNew;
48+
}
49+
50+
/**
51+
* Set is object new
52+
*
53+
* @param bool $isNew
54+
* @return $this
55+
*/
56+
public function setIsObjectNew($isNew)
57+
{
58+
$this->isObjectNew = $isNew;
59+
return $this;
60+
}
61+
62+
/**
63+
* Get type ID
64+
*
65+
* @return string|null
66+
*/
67+
public function getTypeId()
68+
{
69+
return $this->typeId;
70+
}
71+
72+
/**
73+
* Set type ID
74+
*
75+
* @param string|null $typeId
76+
* @return $this
77+
*/
78+
public function setTypeId($typeId)
79+
{
80+
$this->typeId = $typeId;
81+
return $this;
82+
}
83+
}
84+
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\Framework\Test\Unit\Helper;
9+
10+
use Magento\Framework\Model\ResourceModel\AbstractResource;
11+
12+
/**
13+
* Test helper for AbstractResource
14+
*
15+
* This helper extends the concrete AbstractResource class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class AbstractResourceTestHelper extends AbstractResource
19+
{
20+
/**
21+
* @var string
22+
*/
23+
private $idFieldName = 'id';
24+
25+
/**
26+
* Get ID field name
27+
*
28+
* @return string
29+
*/
30+
public function getIdFieldName()
31+
{
32+
return $this->idFieldName;
33+
}
34+
35+
/**
36+
* Set ID field name
37+
*
38+
* @param string $fieldName
39+
* @return $this
40+
*/
41+
public function setIdFieldName($fieldName)
42+
{
43+
$this->idFieldName = $fieldName;
44+
return $this;
45+
}
46+
47+
/**
48+
* Resource initialization
49+
*
50+
* @return void
51+
*/
52+
protected function _construct()
53+
{
54+
// Empty implementation for testing
55+
}
56+
57+
/**
58+
* Get connection
59+
*
60+
* @return mixed
61+
*/
62+
public function getConnection()
63+
{
64+
return null;
65+
}
66+
}
67+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Test\Unit\Helper;
9+
10+
use Magento\Framework\Event\Observer;
11+
12+
/**
13+
* Test helper for Observer
14+
*
15+
* This helper extends the concrete Observer class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class ObserverTestHelper extends Observer
19+
{
20+
/**
21+
* @var mixed
22+
*/
23+
private $controllerAction;
24+
25+
/**
26+
* Constructor that accepts controller action
27+
*
28+
* @param mixed $controllerAction
29+
*/
30+
public function __construct($controllerAction)
31+
{
32+
$this->controllerAction = $controllerAction;
33+
}
34+
35+
/**
36+
* Get controller action
37+
*
38+
* @return mixed
39+
*/
40+
public function getControllerAction()
41+
{
42+
return $this->controllerAction;
43+
}
44+
45+
/**
46+
* Set controller action
47+
*
48+
* @param mixed $action
49+
* @return $this
50+
*/
51+
public function setControllerAction($action)
52+
{
53+
$this->controllerAction = $action;
54+
return $this;
55+
}
56+
}
57+

0 commit comments

Comments
 (0)