14
14
use Magento \AdminAdobeIms \Service \UpdateTokensService ;
15
15
use Magento \AdminAdobeIms \Service \ImsCommandOptionService ;
16
16
use Magento \AdminAdobeIms \Service \ImsConfig ;
17
+ use Magento \Authorization \Model \ResourceModel \Role \Collection as RoleCollection ;
18
+ use Magento \Authorization \Model \ResourceModel \Role \CollectionFactory ;
19
+ use Magento \Authorization \Model \Role ;
17
20
use Magento \Framework \App \Cache \Type \Config ;
18
21
use Magento \Framework \App \Cache \TypeListInterface ;
19
22
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
@@ -64,6 +67,16 @@ class AdminAdobeImsEnableCommandTest extends TestCase
64
67
*/
65
68
private $ questionHelperMock ;
66
69
70
+ /**
71
+ * @var Role
72
+ */
73
+ private $ role ;
74
+
75
+ /**
76
+ * @var CollectionFactory
77
+ */
78
+ private $ roleCollection ;
79
+
67
80
/**
68
81
* @var AdminAdobeImsEnableCommand
69
82
*/
@@ -78,6 +91,28 @@ protected function setUp(): void
78
91
$ this ->imsCommandOptionService = $ this ->createMock (ImsCommandOptionService::class);
79
92
$ this ->typeListInterface = $ this ->createMock (TypeListInterface::class);
80
93
$ this ->updateTokensService = $ this ->createMock (UpdateTokensService::class);
94
+ $ roleCollectionMock = $ this ->createPartialMock (
95
+ RoleCollection::class,
96
+ ['addFieldToFilter ' , 'getSize ' ]
97
+ );
98
+ $ roleCollectionMock ->method ('addFieldToFilter ' )->willReturnSelf ();
99
+ $ this ->roleCollection = $ this ->createPartialMock (
100
+ CollectionFactory::class,
101
+ ['create ' ]
102
+ );
103
+ $ this ->roleCollection ->method ('create ' )->willReturn (
104
+ $ roleCollectionMock
105
+ );
106
+ $ this ->role = $ this ->getMockBuilder (Role::class)
107
+ ->setMethods (['setParentId ' ,'setRoleType ' ,'setUserId ' ,'setRoleName ' ,'setUserType ' ,'save ' ])
108
+ ->disableOriginalConstructor ()
109
+ ->getMock ();
110
+ $ this ->role ->method ('setRoleName ' )->willReturnSelf ();
111
+ $ this ->role ->method ('setUserType ' )->willReturnSelf ();
112
+ $ this ->role ->method ('setUserId ' )->willReturnSelf ();
113
+ $ this ->role ->method ('setRoleType ' )->willReturnSelf ();
114
+ $ this ->role ->method ('setParentId ' )->willReturnSelf ();
115
+ $ this ->role ->method ('save ' )->willReturnSelf ();
81
116
82
117
$ this ->questionHelperMock = $ this ->getMockBuilder (QuestionHelper::class)
83
118
->disableOriginalConstructor ()
@@ -90,7 +125,9 @@ protected function setUp(): void
90
125
'adminImsConnection ' => $ this ->adminImsConnectionMock ,
91
126
'imsCommandOptionService ' => $ this ->imsCommandOptionService ,
92
127
'cacheTypeList ' => $ this ->typeListInterface ,
93
- 'updateTokenService ' => $ this ->updateTokensService
128
+ 'updateTokenService ' => $ this ->updateTokensService ,
129
+ 'role ' => $ this ->role ,
130
+ 'roleCollection ' => $ this ->roleCollection
94
131
]
95
132
);
96
133
}
0 commit comments