Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefaultColumnTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class DefaultColumnTest extends \PHPUnit\Framework\TestCase
11 {
14 
18  protected $defaultColumn;
19 
23  protected $itemMock;
24 
25  protected function setUp()
26  {
27  $this->objectManagerHelper = new ObjectManagerHelper($this);
28  $this->defaultColumn = $this->objectManagerHelper->getObject(
29  \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn::class
30  );
31  $this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
32  ->disableOriginalConstructor()
33  ->setMethods(['getRowTotal', 'getDiscountAmount', 'getBaseRowTotal', 'getBaseDiscountAmount', '__wakeup'])
34  ->getMock();
35  }
36 
37  public function testGetTotalAmount()
38  {
39  $rowTotal = 10;
40  $discountAmount = 2;
41  $expectedResult = 8;
42  $this->itemMock->expects($this->once())
43  ->method('getRowTotal')
44  ->will($this->returnValue($rowTotal));
45  $this->itemMock->expects($this->once())
46  ->method('getDiscountAmount')
47  ->will($this->returnValue($discountAmount));
48  $this->assertEquals($expectedResult, $this->defaultColumn->getTotalAmount($this->itemMock));
49  }
50 
51  public function testGetBaseTotalAmount()
52  {
53  $baseRowTotal = 10;
54  $baseDiscountAmount = 2;
55  $expectedResult = 8;
56  $this->itemMock->expects($this->once())
57  ->method('getBaseRowTotal')
58  ->will($this->returnValue($baseRowTotal));
59  $this->itemMock->expects($this->once())
60  ->method('getBaseDiscountAmount')
61  ->will($this->returnValue($baseDiscountAmount));
62  $this->assertEquals($expectedResult, $this->defaultColumn->getBaseTotalAmount($this->itemMock));
63  }
64 }