Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CheckmoConfigProviderTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class CheckmoConfigProviderTest extends \PHPUnit\Framework\TestCase
13 {
15  protected $model;
16 
18  protected $methodMock;
19 
21  protected $escaperMock;
22 
23  protected function setUp()
24  {
25  $this->methodMock = $this->createMock(\Magento\OfflinePayments\Model\Checkmo::class);
26 
27  $paymentHelperMock = $this->createMock(\Magento\Payment\Helper\Data::class);
28  $paymentHelperMock->expects($this->once())
29  ->method('getMethodInstance')
31  ->willReturn($this->methodMock);
32 
33  $this->escaperMock = $this->createMock(\Magento\Framework\Escaper::class);
34  $this->escaperMock->expects($this->any())
35  ->method('escapeHtml')
36  ->willReturnArgument(0);
37 
38  $this->model = new CheckmoConfigProvider(
39  $paymentHelperMock,
40  $this->escaperMock
41  );
42  }
43 
51  public function testGetConfig($isAvailable, $mailingAddress, $payableTo, $result)
52  {
53  $this->methodMock->expects($this->once())
54  ->method('isAvailable')
55  ->willReturn($isAvailable);
56  $this->methodMock->expects($this->any())
57  ->method('getMailingAddress')
58  ->willReturn($mailingAddress);
59  $this->methodMock->expects($this->any())
60  ->method('getPayableTo')
61  ->willReturn($payableTo);
62 
63  $this->assertEquals($result, $this->model->getConfig());
64  }
65 
69  public function dataProviderGetConfig()
70  {
72  return [
73  [false, '', '', []],
74  [true, '', '', ['payment' => [$checkmoCode => ['mailingAddress' => '', 'payableTo' => '']]]],
75  [true, 'address', '', ['payment' => [$checkmoCode => ['mailingAddress' => 'address', 'payableTo' => '']]]],
76  [true, '', 'to', ['payment' => [$checkmoCode => ['mailingAddress' => '', 'payableTo' => 'to']]]],
77  [true, 'addr', 'to', ['payment' => [$checkmoCode => ['mailingAddress' => 'addr', 'payableTo' => 'to']]]],
78  [false, 'addr', 'to', []],
79  ];
80  }
81 }
testGetConfig($isAvailable, $mailingAddress, $payableTo, $result)