Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CanUseForCountryTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class CanUseForCountryTest extends \PHPUnit\Framework\TestCase
12 {
17 
21  protected $countryProvider;
22 
26  protected $_model;
27 
28  protected function setUp()
29  {
30  $this->countryProvider = $this->createMock(
31  \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider::class
32  );
33  $this->_model = new CanUseForCountry($this->countryProvider);
34  }
35 
40  public function testIsApplicable($expectation)
41  {
42  $quoteMock = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods(
43  []
44  )->getMock();
45 
46  $paymentMethod = $this->getMockBuilder(
47  \Magento\Payment\Model\MethodInterface::class
48  )->disableOriginalConstructor()->setMethods([])->getMock();
49  $paymentMethod->expects($this->once())->method('canUseForCountry')->with(
50  self::EXPECTED_COUNTRY_ID
51  )->will($this->returnValue($expectation));
52  $this->countryProvider->expects($this->once())->method('getCountry')->willReturn(self::EXPECTED_COUNTRY_ID);
53 
54  $this->assertEquals($expectation, $this->_model->isApplicable($paymentMethod, $quoteMock));
55  }
56 
60  public function paymentMethodDataProvider()
61  {
62  return [[true], [false]];
63  }
64 }