Skip to content

Commit 7854577

Browse files
Merge branch '2.4-develop' into graphql-api-enhancements
2 parents 5afe38c + 297b774 commit 7854577

29 files changed

+3632
-66
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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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\Session;
11+
use Magento\Framework\Session\Test\Unit\Helper\StorageTestHelper;
12+
use Magento\User\Model\User;
13+
14+
/**
15+
* Test helper for creating Auth Session mocks with various methods
16+
*
17+
* This helper extends the concrete Auth\Session class directly, providing a clean
18+
* way to add test-specific methods without using anonymous classes.
19+
* Extends Auth\Session to be compatible with type hints requiring that specific class.
20+
*
21+
* METHODS PROVIDED:
22+
* - setUser() / getUser() - User management
23+
* - setIsLoggedIn() / isLoggedIn() - Login state management
24+
* - setSkipLoggingAction() - Logging control
25+
*/
26+
class SessionTestHelper extends Session
27+
{
28+
/**
29+
* @var User|null
30+
*/
31+
private $user = null;
32+
33+
/**
34+
* @var bool
35+
*/
36+
private $isLoggedIn = false;
37+
38+
public function __construct()
39+
{
40+
// Skip parent constructor for testing
41+
// Initialize storage with the StorageTestHelper
42+
$this->storage = new StorageTestHelper();
43+
}
44+
45+
/**
46+
* Get user
47+
*
48+
* @return User|null
49+
*/
50+
public function getUser()
51+
{
52+
return $this->user;
53+
}
54+
55+
/**
56+
* Set user
57+
*
58+
* @param User $user
59+
* @return $this
60+
*/
61+
public function setUser($user)
62+
{
63+
$this->user = $user;
64+
$this->isLoggedIn = true;
65+
return $this;
66+
}
67+
68+
/**
69+
* Set skip logging action
70+
*
71+
* @param mixed $value
72+
* @return $this
73+
*/
74+
public function setSkipLoggingAction($value)
75+
{
76+
// Store in parent's storage using magic method (via StorageTestHelper::__call)
77+
// phpcs:ignore Magento2.Functions.StaticFunction
78+
/** @phpstan-ignore-next-line - StorageTestHelper::__call handles dynamic methods */
79+
$this->storage->setSkipLoggingAction($value);
80+
return $this;
81+
}
82+
83+
/**
84+
* Check if user is logged in
85+
*
86+
* @return bool
87+
*/
88+
public function isLoggedIn()
89+
{
90+
return $this->isLoggedIn;
91+
}
92+
93+
/**
94+
* Set is logged in
95+
*
96+
* @param bool $value
97+
* @return $this
98+
*/
99+
public function setIsLoggedIn($value)
100+
{
101+
$this->isLoggedIn = $value;
102+
return $this;
103+
}
104+
}

0 commit comments

Comments
 (0)