59 protected function setUp()
61 $this->request = $this->createPartialMock(\
Magento\Framework\
App\RequestInterface::class, [
73 $this->response = $this->createMock(\
Magento\Framework\
App\Console\Response::class);
77 $eventManager = $this->createMock(\
Magento\Framework\Event\ManagerInterface::class);
79 $update = $this->createMock(\
Magento\Framework\View\Layout\ProcessorInterface::class);
81 $layout = $this->createMock(\
Magento\Framework\View\Layout::class);
82 $layout->expects($this->any())->method(
'getUpdate')->will($this->returnValue($update));
84 $pageConfig = $this->createMock(\
Magento\Framework\View\Page\Config::class);
85 $pageConfig->expects($this->any())->method(
'addBodyClass')->will($this->returnSelf());
87 $page = $this->createPartialMock(
88 \
Magento\Framework\View\Result\Page::class,
89 [
'getConfig',
'initLayout',
'addPageLayoutHandles',
'getLayout']
91 $page->expects($this->any())->method(
'getConfig')->will($this->returnValue($pageConfig));
92 $page->expects($this->any())->method(
'addPageLayoutHandles')->will($this->returnSelf());
93 $page->expects($this->any())->method(
'getLayout')->will($this->returnValue($layout));
96 $view = $this->createMock(\
Magento\Framework\
App\ViewInterface::class);
97 $view->expects($this->any())->method(
'getLayout')->will($this->returnValue($layout));
100 $resultFactory = $this->createMock(\
Magento\Framework\Controller\ResultFactory::class);
101 $resultFactory->expects($this->any())->method(
'create')->will($this->returnValue(
$page));
103 $this->context = $this->createMock(\
Magento\Backend\
App\Action\Context::class);
104 $this->context->expects($this->any())->method(
'getRequest')->will($this->returnValue($this->request));
105 $this->context->expects($this->any())->method(
'getResponse')->will($this->returnValue($this->response));
106 $this->context->expects($this->any())->method(
'getObjectManager')
108 $this->context->expects($this->any())->method(
'getEventManager')->will($this->returnValue($eventManager));
109 $this->context->expects($this->any())->method(
'getView')->will($this->returnValue($view));
110 $this->context->expects($this->any())->method(
'getResultFactory')
111 ->will($this->returnValue($resultFactory));
113 $this->helperMock = $this->createMock(\
Magento\Framework\Oauth\Helper\Request::class);
114 $this->frameworkOauthSvcMock = $this->createMock(\
Magento\Framework\Oauth\OauthInterface::class);
115 $this->intOauthServiceMock = $this->createMock(\
Magento\Integration\Api\OauthServiceInterface::class);
116 $this->integrationServiceMock = $this->createMock(\
Magento\Integration\Api\IntegrationServiceInterface::class);
118 $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
119 $this->accessAction = $this->objectManagerHelper->getObject(
122 'context' => $this->context,
123 'oauthService'=> $this->frameworkOauthSvcMock,
124 'intOauthService' => $this->intOauthServiceMock,
125 'integrationService' => $this->integrationServiceMock,
126 'helper' => $this->helperMock,
134 public function testAccessAction()
136 $this->request->expects($this->any())
137 ->method(
'getMethod')
139 $this->helperMock->expects($this->once())
140 ->method(
'getRequestUrl');
141 $this->helperMock->expects($this->once())
142 ->method(
'prepareRequest');
143 $this->frameworkOauthSvcMock->expects($this->once())
144 ->method(
'getAccessToken')
145 ->willReturn([
'response']);
147 $consumerMock = $this->createMock(\
Magento\Integration\Model\Oauth\Consumer::class);
148 $consumerMock->expects($this->once())
150 $this->intOauthServiceMock->expects($this->once())
151 ->method(
'loadConsumerByKey')
152 ->willReturn($consumerMock);
154 $integrationMock = $this->createMock(\
Magento\Integration\Model\Integration::class);
155 $integrationMock->expects($this->once())
158 $this->integrationServiceMock->expects($this->once())
159 ->method(
'findByConsumerId')
160 ->willReturn($integrationMock);
161 $this->response->expects($this->once())
164 $this->accessAction->execute();