1414use Magento \AdminAdobeIms \Service \UpdateTokensService ;
1515use Magento \AdminAdobeIms \Service \ImsCommandOptionService ;
1616use 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 ;
1720use Magento \Framework \App \Cache \Type \Config ;
1821use Magento \Framework \App \Cache \TypeListInterface ;
1922use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
@@ -64,6 +67,16 @@ class AdminAdobeImsEnableCommandTest extends TestCase
6467 */
6568 private $ questionHelperMock ;
6669
70+ /**
71+ * @var Role
72+ */
73+ private $ role ;
74+
75+ /**
76+ * @var CollectionFactory
77+ */
78+ private $ roleCollection ;
79+
6780 /**
6881 * @var AdminAdobeImsEnableCommand
6982 */
@@ -78,6 +91,28 @@ protected function setUp(): void
7891 $ this ->imsCommandOptionService = $ this ->createMock (ImsCommandOptionService::class);
7992 $ this ->typeListInterface = $ this ->createMock (TypeListInterface::class);
8093 $ 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 ();
81116
82117 $ this ->questionHelperMock = $ this ->getMockBuilder (QuestionHelper::class)
83118 ->disableOriginalConstructor ()
@@ -90,7 +125,9 @@ protected function setUp(): void
90125 'adminImsConnection ' => $ this ->adminImsConnectionMock ,
91126 'imsCommandOptionService ' => $ this ->imsCommandOptionService ,
92127 'cacheTypeList ' => $ this ->typeListInterface ,
93- 'updateTokenService ' => $ this ->updateTokensService
128+ 'updateTokenService ' => $ this ->updateTokensService ,
129+ 'role ' => $ this ->role ,
130+ 'roleCollection ' => $ this ->roleCollection
94131 ]
95132 );
96133 }
0 commit comments