Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CheckmoTest.php
Go to the documentation of this file.
1 <?php
7 
11 use PHPUnit_Framework_MockObject_MockObject as MockObject;
12 
16 class CheckmoTest extends \PHPUnit\Framework\TestCase
17 {
21  private $info;
22 
26  private $block;
27 
31  protected function setUp()
32  {
33  $context = $this->getMockBuilder(Context::class)
34  ->disableOriginalConstructor()
35  ->setMethods([])
36  ->getMock();
37 
38  $this->info = $this->getMockBuilder(Info::class)
39  ->disableOriginalConstructor()
40  ->setMethods(['getAdditionalInformation'])
41  ->getMock();
42 
43  $this->block = new Checkmo($context);
44  }
45 
52  public function testGetPayableTo($details, $expected)
53  {
54  $this->info->expects(static::at(0))
55  ->method('getAdditionalInformation')
56  ->with('payable_to')
57  ->willReturn($details);
58  $this->block->setData('info', $this->info);
59 
60  static::assertEquals($expected, $this->block->getPayableTo());
61  }
62 
67  public function getPayableToDataProvider()
68  {
69  return [
70  ['payable_to' => 'payable', 'payable'],
71  ['', null]
72  ];
73  }
74 
81  public function testGetMailingAddress($details, $expected)
82  {
83  $this->info->expects(static::at(1))
84  ->method('getAdditionalInformation')
85  ->with('mailing_address')
86  ->willReturn($details);
87  $this->block->setData('info', $this->info);
88 
89  static::assertEquals($expected, $this->block->getMailingAddress());
90  }
91 
97  {
98  return [
99  ['mailing_address' => '[email protected]', '[email protected]'],
100  ['mailing_address' => '', null]
101  ];
102  }
103 
108  {
109  $mailingAddress = '[email protected]';
110  $this->info->expects(static::at(1))
111  ->method('getAdditionalInformation')
112  ->with('mailing_address')
113  ->willReturn($mailingAddress);
114  $this->block->setData('info', $this->info);
115 
116  // First we set the property $this->_mailingAddress
117  $this->block->getMailingAddress();
118 
119  // And now we get already setted property $this->_mailingAddress
120  static::assertEquals($mailingAddress, $this->block->getMailingAddress());
121  }
122 }
$details
Definition: vault.phtml:10