InstructionsTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Test class for \Magento\Payment\Block\Info\Instructions
  8. */
  9. namespace Magento\Payment\Test\Unit\Block\Info;
  10. class InstructionsTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Payment\Model\Info|\PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $_info;
  16. /**
  17. * @var \Magento\Payment\Block\Info\Instructions
  18. */
  19. protected $_instructions;
  20. protected function setUp()
  21. {
  22. $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
  23. $this->_instructions = new \Magento\Payment\Block\Info\Instructions($context);
  24. $this->_info = $this->createMock(\Magento\Payment\Model\Info::class);
  25. $this->_instructions->setData('info', $this->_info);
  26. }
  27. public function testGetInstructionAdditionalInformation()
  28. {
  29. $this->_info->expects($this->once())
  30. ->method('getAdditionalInformation')
  31. ->with('instructions')
  32. ->willReturn('get the instruction here');
  33. $this->assertEquals('get the instruction here', $this->_instructions->getInstructions());
  34. // And we get the already setted param $this->_instructions
  35. $this->assertEquals('get the instruction here', $this->_instructions->getInstructions());
  36. }
  37. public function testGetInstruction()
  38. {
  39. $methodInstance = $this->getMockBuilder(
  40. \Magento\Payment\Model\MethodInterface::class
  41. )->getMockForAbstractClass();
  42. $methodInstance->expects($this->once())
  43. ->method('getConfigData')
  44. ->with('instructions')
  45. ->willReturn('get the instruction here');
  46. $this->_info->expects($this->once())
  47. ->method('getAdditionalInformation')
  48. ->with('instructions')
  49. ->willReturn(false);
  50. $this->_info->expects($this->once())
  51. ->method('getMethodInstance')
  52. ->willReturn($methodInstance);
  53. $this->assertEquals('get the instruction here', $this->_instructions->getInstructions());
  54. }
  55. }