Skip to content

Commit c5b01ad

Browse files
Merge remote-tracking branch 'origin/Arrows-AC-15800-Test_Helpers' into AC-15635
2 parents 7d4e905 + 82d32ea commit c5b01ad

File tree

671 files changed

+36070
-14384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

671 files changed

+36070
-14384
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Authorization\Test\Unit\Helper;
9+
10+
use Magento\Authorization\Model\Role;
11+
12+
/**
13+
* Test helper for Magento\Authorization\Model\Role
14+
*
15+
* This helper provides only the custom GWS-related methods that are not available
16+
* in the parent Role class. Standard methods like getData(), setData(), and load()
17+
* are inherited from Magento\Framework\Model\AbstractModel.
18+
*/
19+
class RoleTestHelper extends Role
20+
{
21+
/**
22+
* @var array
23+
*/
24+
private $gwsWebsites = [];
25+
26+
/**
27+
* @var array
28+
*/
29+
private $gwsStoreGroups = [];
30+
31+
/**
32+
* @var bool
33+
*/
34+
private $gwsDataIsset = false;
35+
36+
/**
37+
* Skip parent constructor to avoid dependency injection requirements in tests
38+
*/
39+
public function __construct()
40+
{
41+
// Intentionally empty - avoids parent constructor dependencies
42+
}
43+
44+
/**
45+
* Get GWS websites
46+
*
47+
* @return array
48+
*/
49+
public function getGwsWebsites()
50+
{
51+
return $this->gwsWebsites;
52+
}
53+
54+
/**
55+
* Set GWS websites
56+
*
57+
* @param array $websites
58+
* @return $this
59+
*/
60+
public function setGwsWebsites($websites)
61+
{
62+
$this->gwsWebsites = $websites;
63+
return $this;
64+
}
65+
66+
/**
67+
* Get GWS store groups
68+
*
69+
* @return array
70+
*/
71+
public function getGwsStoreGroups()
72+
{
73+
return $this->gwsStoreGroups;
74+
}
75+
76+
/**
77+
* Set GWS store groups
78+
*
79+
* @param array $storeGroups
80+
* @return $this
81+
*/
82+
public function setGwsStoreGroups($storeGroups)
83+
{
84+
$this->gwsStoreGroups = $storeGroups;
85+
return $this;
86+
}
87+
88+
/**
89+
* Set GWS data isset flag
90+
*
91+
* @param bool $value
92+
* @return $this
93+
*/
94+
public function setGwsDataIsset($value)
95+
{
96+
$this->gwsDataIsset = $value;
97+
return $this;
98+
}
99+
100+
/**
101+
* Load role (overridden to avoid database access in tests)
102+
*
103+
* @param mixed $modelId
104+
* @param string|null $field
105+
* @return $this
106+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
107+
*/
108+
public function load($modelId, $field = null)
109+
{
110+
return $this;
111+
}
112+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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\Test\Unit\App\Action\Stub\ActionStub;
11+
12+
/**
13+
* Test helper for ActionStub with additional test-specific methods
14+
*
15+
* This helper extends ActionStub to provide the setDirtyRulesNoticeMessage()
16+
* method which is used in production by CatalogRule controllers but doesn't
17+
* exist in the base ActionStub class. Since PHPUnit 12 removed addMethods(),
18+
* this helper is necessary to test code that calls this method.
19+
*
20+
* @SuppressWarnings(PHPMD.AllPurposeAction)
21+
*/
22+
class ActionStubTestHelper extends ActionStub
23+
{
24+
public function __construct()
25+
{
26+
// Skip parent constructor for testing
27+
}
28+
29+
/**
30+
* Stub method for testing CatalogRule controllers
31+
*
32+
* This method is called by AdminGws\Model\Controllers::promoCatalogIndexAction()
33+
* but doesn't exist in the base ActionStub class.
34+
*
35+
* @param string $message
36+
* @return $this
37+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
38+
*/
39+
public function setDirtyRulesNoticeMessage($message)
40+
{
41+
return $this;
42+
}
43+
}
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\Model\Auth\Credential\StorageInterface as CredentialStorage;
11+
12+
class AuthStorageTestHelper implements \Magento\Backend\Model\Auth\StorageInterface
13+
{
14+
/**
15+
* @return $this
16+
*/
17+
public function processLogin()
18+
{
19+
return $this;
20+
}
21+
22+
/**
23+
* @return $this
24+
*/
25+
public function processLogout()
26+
{
27+
return $this;
28+
}
29+
30+
/**
31+
* @return bool
32+
*/
33+
public function isLoggedIn()
34+
{
35+
return true;
36+
}
37+
38+
/**
39+
* @return void
40+
*/
41+
public function prolong()
42+
{
43+
}
44+
45+
/**
46+
* @param string $path
47+
* @return $this
48+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
49+
*/
50+
public function setDeletedPath($path)
51+
{
52+
return $this;
53+
}
54+
}
55+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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\Button;
11+
12+
/**
13+
* Test helper for Button class with custom methods
14+
*/
15+
class ButtonTestHelper extends Button
16+
{
17+
/**
18+
* @var array
19+
*/
20+
private $data = [];
21+
22+
/**
23+
* Skip parent constructor to avoid dependencies
24+
*/
25+
public function __construct()
26+
{
27+
// Skip parent constructor - clean initialization
28+
$this->data = [];
29+
}
30+
31+
/**
32+
* Custom isAllowed method for testing
33+
*
34+
* @param string|null $resource
35+
* @return bool
36+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
37+
*/
38+
public function isAllowed($resource = null): bool
39+
{
40+
return $this->data['is_allowed'] ?? true;
41+
}
42+
43+
/**
44+
* Set is allowed for testing
45+
*
46+
* @param bool $isAllowed
47+
* @return self
48+
*/
49+
public function setIsAllowed(bool $isAllowed): self
50+
{
51+
$this->data['is_allowed'] = $isAllowed;
52+
return $this;
53+
}
54+
55+
/**
56+
* Override getAuthorization method
57+
*
58+
* @return mixed
59+
*/
60+
public function getAuthorization()
61+
{
62+
return $this->data['authorization'] ?? null;
63+
}
64+
65+
/**
66+
* Set authorization for testing
67+
*
68+
* @param mixed $authorization
69+
* @return self
70+
*/
71+
public function setAuthorization($authorization): self
72+
{
73+
$this->data['authorization'] = $authorization;
74+
return $this;
75+
}
76+
77+
/**
78+
* Override toHtml method
79+
*
80+
* @return string
81+
*/
82+
public function toHtml(): string
83+
{
84+
return $this->data['html'] ?? '';
85+
}
86+
87+
/**
88+
* Set HTML output for testing
89+
*
90+
* @param string $html
91+
* @return self
92+
*/
93+
public function setHtml(string $html): self
94+
{
95+
$this->data['html'] = $html;
96+
return $this;
97+
}
98+
}

0 commit comments

Comments
 (0)