Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CartTotalsProcessorTest.php
Go to the documentation of this file.
1 <?php
7 
8 class CartTotalsProcessorTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $model;
14 
18  protected $scopeConfig;
19 
20  protected function setUp()
21  {
22  $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
23  $this->model = new \Magento\Checkout\Block\Cart\CartTotalsProcessor($this->scopeConfig);
24  }
25 
26  public function testProcess()
27  {
28  $configData = [
29  'total_1' => 'sort_1',
30  'total_2' => 'sort_2',
31  'total_3' => 'sort_3'
32  ];
33 
34  $jsLayout = [
35  'components' => [
36  'block-totals' => [
37  'children' => [
38  'total_1' => ['value' => 'value_1', 'sortOrder' => 0],
39  'total_2' => ['value' => 'value_1', 'sortOrder' => 1],
40  'total_3' => ['value' => 'value_1', 'sortOrder' => 2]
41  ]
42  ]
43  ]
44  ];
45 
46  $expected = [
47  'components' => [
48  'block-totals' => [
49  'children' => [
50  'total_1' => ['value' => 'value_1', 'sortOrder' => 'sort_1'],
51  'total_2' => ['value' => 'value_1', 'sortOrder' => 'sort_2'],
52  'total_3' => ['value' => 'value_1', 'sortOrder' => 'sort_3']
53  ]
54  ]
55  ]
56  ];
57 
58  $this->scopeConfig->expects($this->once())
59  ->method('getValue')
60  ->with('sales/totals_sort')
61  ->willReturn($configData);
62 
63  $this->assertEquals($expected, $this->model->process($jsLayout));
64  }
65 }