Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TokensExchangeTest.php
Go to the documentation of this file.
1 <?php
7 
9 {
11  {
12  $controller = $this->_createIntegrationController('TokensExchange');
13 
14  $this->_escaper->expects($this->once())->method('escapeHtml')->willReturnArgument(0);
15 
16  $this->_requestMock->expects($this->any())
17  ->method('getParam')
18  ->willReturnMap(
19  [
20  [
21  \Magento\Integration\Controller\Adminhtml\Integration::PARAM_INTEGRATION_ID,
22  null,
23  self::INTEGRATION_ID,
24  ],
25  [\Magento\Integration\Controller\Adminhtml\Integration::PARAM_REAUTHORIZE, 0, 1],
26  ]
27  );
28 
29  $this->_integrationSvcMock->expects($this->once())
30  ->method('get')
31  ->with($this->equalTo(self::INTEGRATION_ID))
32  ->willReturn($this->_getIntegrationModelMock());
33 
34  $this->_oauthSvcMock->expects($this->once())->method('deleteIntegrationToken');
35  $this->_oauthSvcMock->expects($this->once())->method('postToConsumer');
36  $consumerMock = $this->createMock(\Magento\Integration\Model\Oauth\Consumer::class);
37  $consumerMock->expects($this->once())->method('getId')->willReturn(1);
38  $this->_oauthSvcMock->expects($this->once())->method('loadConsumer')->willReturn($consumerMock);
39 
40  $this->_messageManager->expects($this->once())->method('addNotice');
41  $this->_messageManager->expects($this->never())->method('addError');
42  $this->_messageManager->expects($this->never())->method('addSuccess');
43 
44  $this->_viewMock->expects($this->once())->method('loadLayout');
45  $this->_viewMock->expects($this->once())->method('renderLayout');
46 
47  $this->_responseMock->expects($this->once())->method('getBody');
48  $this->_responseMock->expects($this->once())->method('representJson');
49 
50  $controller->execute();
51  }
52 }
$controller
Definition: info.phtml:14