Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TotalMinMaxTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Payment\Model\Checks\TotalMinMax;
10 
11 class TotalMinMaxTest extends \PHPUnit\Framework\TestCase
12 {
16  const PAYMENT_MIN_TOTAL = 2;
17 
21  const PAYMENT_MAX_TOTAL = 5;
22 
28  public function testIsApplicable($baseGrandTotal, $expectation)
29  {
30  $paymentMethod = $this->getMockBuilder(
31  \Magento\Payment\Model\MethodInterface::class
32  )->disableOriginalConstructor()->setMethods([])->getMock();
33  $paymentMethod->expects($this->at(0))->method('getConfigData')->with(
35  )->will($this->returnValue(self::PAYMENT_MIN_TOTAL));
36  $paymentMethod->expects($this->at(1))->method('getConfigData')->with(
38  )->will($this->returnValue(self::PAYMENT_MAX_TOTAL));
39 
40  $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)->disableOriginalConstructor()->setMethods(
41  ['getBaseGrandTotal', '__wakeup']
42  )->getMock();
43  $quote->expects($this->once())->method('getBaseGrandTotal')->will($this->returnValue($baseGrandTotal));
44 
45  $model = new TotalMinMax();
46  $this->assertEquals($expectation, $model->isApplicable($paymentMethod, $quote));
47  }
48 
52  public function paymentMethodDataProvider()
53  {
54  return [[1, false], [6, false], [3, true]];
55  }
56 }
$quote