Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigTest.php
Go to the documentation of this file.
1 <?php
7 
8 class ConfigTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $model;
14 
18  protected $configDataMock;
19 
23  protected $stateMock;
24 
25  protected function setUp()
26  {
27  $this->configDataMock = $this->getMockBuilder(\Magento\Sales\Model\Config\Data::class)
28  ->disableOriginalConstructor()
29  ->getMock();
30  $this->stateMock = $this->getMockBuilder(\Magento\Framework\App\State::class)
31  ->disableOriginalConstructor()
32  ->getMock();
33  $this->model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock);
34  }
35 
36  public function testInstanceOf()
37  {
38  $model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock);
39  $this->assertInstanceOf(\Magento\Sales\Model\Config::class, $model);
40  }
41 
42  public function testGetTotalsRenderer()
43  {
44  $areaCode = 'frontend';
45  $section = 'config';
46  $group = 'sales';
47  $code = 'payment';
48  $path = $section . '/' . $group . '/' . $code . '/' . 'renderers' . '/' . $areaCode;
49  $expected = ['test data'];
50 
51  $this->stateMock->expects($this->once())
52  ->method('getAreaCode')
53  ->will($this->returnValue($areaCode));
54  $this->configDataMock->expects($this->once())
55  ->method('get')
56  ->with($this->equalTo($path))
57  ->will($this->returnValue($expected));
58 
59  $result = $this->model->getTotalsRenderer($section, $group, $code);
60  $this->assertEquals($expected, $result);
61  }
62 
63  public function testGetGroupTotals()
64  {
65  $section = 'config';
66  $group = 'payment';
67  $expected = ['test data'];
68  $path = $section . '/' . $group;
69 
70  $this->configDataMock->expects($this->once())
71  ->method('get')
72  ->with($this->equalTo($path))
73  ->will($this->returnValue($expected));
74 
75  $result = $this->model->getGroupTotals($section, $group);
76  $this->assertEquals($expected, $result);
77  }
78 
79  public function testGetAvailableProductTypes()
80  {
81  $productTypes = ['simple'];
82 
83  $this->configDataMock->expects($this->once())
84  ->method('get')
85  ->with($this->equalTo('order/available_product_types'))
86  ->will($this->returnValue($productTypes));
87  $result = $this->model->getAvailableProductTypes();
88  $this->assertEquals($productTypes, $result);
89  }
90 }
$group
Definition: sections.phtml:16
$code
Definition: info.phtml:12