TokensExchangeTest.php 2.2 KB

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