Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InstructionsTest.php
Go to the documentation of this file.
1 <?php
11 
12 class InstructionsTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $_info;
18 
22  protected $_instructions;
23 
24  protected function setUp()
25  {
26  $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
27  $this->_instructions = new \Magento\Payment\Block\Info\Instructions($context);
28  $this->_info = $this->createMock(\Magento\Payment\Model\Info::class);
29  $this->_instructions->setData('info', $this->_info);
30  }
31 
33  {
34  $this->_info->expects($this->once())
35  ->method('getAdditionalInformation')
36  ->with('instructions')
37  ->willReturn('get the instruction here');
38  $this->assertEquals('get the instruction here', $this->_instructions->getInstructions());
39 
40  // And we get the already setted param $this->_instructions
41  $this->assertEquals('get the instruction here', $this->_instructions->getInstructions());
42  }
43 
44  public function testGetInstruction()
45  {
46  $methodInstance = $this->getMockBuilder(
47  \Magento\Payment\Model\MethodInterface::class
48  )->getMockForAbstractClass();
49  $methodInstance->expects($this->once())
50  ->method('getConfigData')
51  ->with('instructions')
52  ->willReturn('get the instruction here');
53  $this->_info->expects($this->once())
54  ->method('getAdditionalInformation')
55  ->with('instructions')
56  ->willReturn(false);
57  $this->_info->expects($this->once())
58  ->method('getMethodInstance')
59  ->willReturn($methodInstance);
60  $this->assertEquals('get the instruction here', $this->_instructions->getInstructions());
61  }
62 }