Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CanUseForCurrencyTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Payment\Model\Checks\CanUseForCurrency;
10 
11 class CanUseForCurrencyTest extends \PHPUnit\Framework\TestCase
12 {
16  const EXPECTED_CURRENCY_CODE = 'US';
17 
21  protected $_model;
22 
23  protected function setUp()
24  {
25  $this->_model = new CanUseForCurrency();
26  }
27 
32  public function testIsApplicable($expectation)
33  {
34  $paymentMethod = $this->getMockBuilder(
35  \Magento\Payment\Model\MethodInterface::class
36  )->disableOriginalConstructor()->setMethods([])->getMock();
37  $paymentMethod->expects($this->once())->method('canUseForCurrency')->with(
38  self::EXPECTED_CURRENCY_CODE
39  )->will($this->returnValue($expectation));
40 
41  $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods(
42  []
43  )->getMock();
44  $store = $this->getMockBuilder(
45  \Magento\Store\Model\Store::class
46  )->disableOriginalConstructor()->setMethods([])->getMock();
47  $store->expects($this->once())->method('getBaseCurrencyCode')->will(
48  $this->returnValue(self::EXPECTED_CURRENCY_CODE)
49  );
50  $quoteMock->expects($this->once())->method('getStore')->will($this->returnValue($store));
51 
52  $this->assertEquals($expectation, $this->_model->isApplicable($paymentMethod, $quoteMock));
53  }
54 
58  public function paymentMethodDataProvider()
59  {
60  return [[true], [false]];
61  }
62 }