Skip to content

Commit 2fed0f3

Browse files
AC-15108: PHPUnit 12 Upgrade | Refactoring helper classes
1 parent 48e4c73 commit 2fed0f3

File tree

6 files changed

+278
-58
lines changed

6 files changed

+278
-58
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Test\Unit\Helper;
9+
10+
use Magento\Backend\Model\Session\Quote;
11+
12+
/**
13+
* Test helper for Session\Quote
14+
*
15+
* This helper extends the concrete Session\Quote class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class SessionQuoteTestHelper extends Quote
19+
{
20+
/**
21+
* Constructor that skips parent initialization
22+
*/
23+
public function __construct()
24+
{
25+
// Skip parent constructor to avoid dependency injection issues
26+
}
27+
28+
/**
29+
* Get store ID
30+
*
31+
* @return int
32+
*/
33+
public function getStoreId()
34+
{
35+
return 1;
36+
}
37+
}
38+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Test\Unit\Helper;
9+
10+
use Magento\Backend\Model\Session;
11+
12+
/**
13+
* Test helper for Session
14+
*
15+
* This helper extends the concrete Session class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class SessionTestHelper extends Session
19+
{
20+
/**
21+
* Constructor without dependencies
22+
*/
23+
public function __construct()
24+
{
25+
// Skip parent constructor to avoid dependency injection issues
26+
}
27+
28+
/**
29+
* Set URL notice flag
30+
*
31+
* @param bool $flag
32+
* @return $this
33+
*/
34+
public function setIsUrlNotice($flag)
35+
{
36+
return $this;
37+
}
38+
}
39+
Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
<?php
22
/**
3-
* Copyright 2025 Adobe
3+
* Copyright 2016 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Quote\Test\Unit\Helper;
99

10-
use Magento\Quote\Api\Data\CartExtensionInterface;
10+
use Magento\Quote\Api\Data\CartExtension;
11+
use Magento\NegotiableQuote\Api\Data\NegotiableQuoteInterface;
1112

1213
/**
13-
* Test helper for CartExtension to support dynamic getNegotiableQuote/setNegotiableQuote methods
14+
* Test helper for CartExtension
15+
*
16+
* This helper extends the concrete CartExtension class to provide
17+
* test-specific functionality without dependency injection issues.
1418
*/
15-
class CartExtensionTestHelper implements CartExtensionInterface
19+
class CartExtensionTestHelper extends CartExtension
1620
{
1721
/**
18-
* @var \Magento\NegotiableQuote\Api\Data\NegotiableQuoteInterface|null
22+
* @var NegotiableQuoteInterface
1923
*/
2024
private $negotiableQuote;
2125

2226
/**
23-
* @var array
27+
* Constructor that skips parent initialization
2428
*/
25-
private $shippingAssignments = [];
26-
27-
/**
28-
* @var int|null
29-
*/
30-
private $companyId;
29+
public function __construct()
30+
{
31+
// Skip parent constructor to avoid dependency injection issues
32+
}
3133

3234
/**
3335
* Get negotiable quote
3436
*
35-
* @return \Magento\NegotiableQuote\Api\Data\NegotiableQuoteInterface|null
37+
* @return NegotiableQuoteInterface|null
3638
*/
3739
public function getNegotiableQuote()
3840
{
@@ -42,56 +44,12 @@ public function getNegotiableQuote()
4244
/**
4345
* Set negotiable quote
4446
*
45-
* @param \Magento\NegotiableQuote\Api\Data\NegotiableQuoteInterface|null $negotiableQuote
47+
* @param NegotiableQuoteInterface $negotiableQuote
4648
* @return $this
4749
*/
4850
public function setNegotiableQuote($negotiableQuote)
4951
{
5052
$this->negotiableQuote = $negotiableQuote;
5153
return $this;
5254
}
53-
54-
/**
55-
* Get shipping assignments
56-
*
57-
* @return \Magento\Quote\Api\Data\ShippingAssignmentInterface[]|null
58-
*/
59-
public function getShippingAssignments()
60-
{
61-
return $this->shippingAssignments;
62-
}
63-
64-
/**
65-
* Set shipping assignments
66-
*
67-
* @param \Magento\Quote\Api\Data\ShippingAssignmentInterface[] $shippingAssignments
68-
* @return $this
69-
*/
70-
public function setShippingAssignments($shippingAssignments)
71-
{
72-
$this->shippingAssignments = $shippingAssignments;
73-
return $this;
74-
}
75-
76-
/**
77-
* Get company ID
78-
*
79-
* @return int|null
80-
*/
81-
public function getCompanyId()
82-
{
83-
return $this->companyId;
84-
}
85-
86-
/**
87-
* Set company ID
88-
*
89-
* @param int|null $companyId
90-
* @return $this
91-
*/
92-
public function setCompanyId($companyId)
93-
{
94-
$this->companyId = $companyId;
95-
return $this;
96-
}
9755
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Quote\Test\Unit\Helper;
9+
10+
use Magento\Quote\Model\Quote;
11+
12+
/**
13+
* Test helper for Quote
14+
*
15+
* This helper extends the concrete Quote class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class QuoteTestHelper extends Quote
19+
{
20+
/**
21+
* @var array
22+
*/
23+
private $visibleItems = [];
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+
* Set super mode
35+
*
36+
* @param mixed $value
37+
* @return $this
38+
*/
39+
public function setIsSuperMode($value)
40+
{
41+
return $this;
42+
}
43+
44+
/**
45+
* Get all visible items
46+
*
47+
* @return array
48+
*/
49+
public function getAllVisibleItems()
50+
{
51+
return $this->visibleItems;
52+
}
53+
54+
/**
55+
* Set visible items
56+
*
57+
* @param array $items
58+
* @return $this
59+
*/
60+
public function setVisibleItems($items)
61+
{
62+
$this->visibleItems = $items;
63+
return $this;
64+
}
65+
}
66+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Test\Unit\Helper;
9+
10+
use Magento\Framework\View\Result\Page;
11+
use Magento\Framework\View\Page\Config;
12+
13+
/**
14+
* Test helper for Page
15+
*
16+
* This helper extends the concrete Page class to provide
17+
* test-specific functionality without dependency injection issues.
18+
*/
19+
class PageTestHelper extends Page
20+
{
21+
/**
22+
* @var Config
23+
*/
24+
private $config;
25+
26+
/**
27+
* Constructor that accepts config
28+
*
29+
* @param Config $config
30+
*/
31+
public function __construct($config)
32+
{
33+
$this->config = $config;
34+
}
35+
36+
/**
37+
* Set active menu
38+
*
39+
* @param string $menuId
40+
* @return $this
41+
*/
42+
public function setActiveMenu($menuId)
43+
{
44+
return $this;
45+
}
46+
47+
/**
48+
* Add breadcrumb
49+
*
50+
* @param string $label
51+
* @param string $title
52+
* @param string|null $link
53+
* @return $this
54+
*/
55+
public function addBreadcrumb($label, $title, $link = null)
56+
{
57+
return $this;
58+
}
59+
60+
/**
61+
* Get config
62+
*
63+
* @return Config
64+
*/
65+
public function getConfig()
66+
{
67+
return $this->config;
68+
}
69+
}
70+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Test\Unit\Helper;
9+
10+
use Magento\Framework\View\Element\Template;
11+
12+
/**
13+
* Test helper for Template
14+
*
15+
* This helper extends the concrete Template class to provide
16+
* test-specific functionality without dependency injection issues.
17+
*/
18+
class TemplateTestHelper extends Template
19+
{
20+
/**
21+
* Constructor that skips parent initialization
22+
*/
23+
public function __construct()
24+
{
25+
// Skip parent constructor to avoid dependency injection issues
26+
}
27+
28+
/**
29+
* Set item
30+
*
31+
* @param mixed $item
32+
* @return $this
33+
*/
34+
public function setItem($item)
35+
{
36+
return $this;
37+
}
38+
39+
/**
40+
* Render HTML
41+
*
42+
* @return string
43+
*/
44+
public function toHtml()
45+
{
46+
return 'rendered';
47+
}
48+
}
49+

0 commit comments

Comments
 (0)