Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TotalsProcessorTest.php
Go to the documentation of this file.
1 <?php
8 
9 class TotalsProcessorTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $model;
15 
19  protected $scopeConfigMock;
20 
21  protected function setUp()
22  {
23  $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
24 
25  $this->model = new \Magento\Checkout\Block\Checkout\TotalsProcessor($this->scopeConfigMock);
26  }
27 
28  public function testProcess()
29  {
30  $jsLayoutData = [
31  'sub-total' => [],
32  'grand-total' => [],
33  'non-existant-total' => null
34  ];
35  $expectedResultData = [
36  'sub-total' => ['sortOrder' => 10],
37  'grand-total' => ['sortOrder' => 20],
38  'non-existant-total' => null
39  ];
40  $jsLayout['components']['checkout']['children']['sidebar']['children']['summary']
41  ['children']['totals']['children'] = $jsLayoutData;
42  $expectedResult['components']['checkout']['children']['sidebar']['children']['summary']
43  ['children']['totals']['children'] = $expectedResultData;
44 
45  $configData = ['sub_total' => 10, 'grand_total' => 20];
46 
47  $this->scopeConfigMock->expects($this->once())->method('getValue')->with('sales/totals_sort')
48  ->willReturn($configData);
49 
50  $this->assertEquals($expectedResult, $this->model->process($jsLayout));
51  }
52 }