1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Integration\Test\Unit\Controller\Adminhtml\Integration;
class TokensExchangeTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\IntegrationTest
{
public function testTokensExchangeReauthorize()
{
$controller = $this->_createIntegrationController('TokensExchange');
$this->_escaper->expects($this->once())->method('escapeHtml')->willReturnArgument(0);
$this->_requestMock->expects($this->any())
->method('getParam')
->willReturnMap(
[
[
\Magento\Integration\Controller\Adminhtml\Integration::PARAM_INTEGRATION_ID,
null,
self::INTEGRATION_ID,
],
[\Magento\Integration\Controller\Adminhtml\Integration::PARAM_REAUTHORIZE, 0, 1],
]
);
$this->_integrationSvcMock->expects($this->once())
->method('get')
->with($this->equalTo(self::INTEGRATION_ID))
->willReturn($this->_getIntegrationModelMock());
$this->_oauthSvcMock->expects($this->once())->method('deleteIntegrationToken');
$this->_oauthSvcMock->expects($this->once())->method('postToConsumer');
$consumerMock = $this->createMock(\Magento\Integration\Model\Oauth\Consumer::class);
$consumerMock->expects($this->once())->method('getId')->willReturn(1);
$this->_oauthSvcMock->expects($this->once())->method('loadConsumer')->willReturn($consumerMock);
$this->_messageManager->expects($this->once())->method('addNotice');
$this->_messageManager->expects($this->never())->method('addError');
$this->_messageManager->expects($this->never())->method('addSuccess');
$this->_viewMock->expects($this->once())->method('loadLayout');
$this->_viewMock->expects($this->once())->method('renderLayout');
$this->_responseMock->expects($this->once())->method('getBody');
$this->_responseMock->expects($this->once())->method('representJson');
$controller->execute();
}
}