Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ZeroTotalTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Payment\Model\Checks\ZeroTotal;
10 
11 class ZeroTotalTest extends \PHPUnit\Framework\TestCase
12 {
19  public function testIsApplicable($code, $total, $expectation)
20  {
21  $paymentMethod = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class)
22  ->disableOriginalConstructor()
23  ->setMethods([])
24  ->getMock();
25 
26  if (!$total) {
27  $paymentMethod->expects($this->once())
28  ->method('getCode')
29  ->will($this->returnValue($code));
30  }
31 
32  $quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)
33  ->disableOriginalConstructor()
34  ->setMethods(['getBaseGrandTotal', '__wakeup'])
35  ->getMock();
36 
37  $quote->expects($this->once())
38  ->method('getBaseGrandTotal')
39  ->will($this->returnValue($total));
40 
41  $model = new ZeroTotal();
42  $this->assertEquals($expectation, $model->isApplicable($paymentMethod, $quote));
43  }
44 
48  public function paymentMethodDataProvider()
49  {
50  return [['not_free', 0, false], ['free', 1, true]];
51  }
52 }
$quote
$code
Definition: info.phtml:12