123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Sales\Test\Unit\Model;
- class ConfigTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \Magento\Sales\Model\Config
- */
- protected $model;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $configDataMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $stateMock;
- protected function setUp()
- {
- $this->configDataMock = $this->getMockBuilder(\Magento\Sales\Model\Config\Data::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->stateMock = $this->getMockBuilder(\Magento\Framework\App\State::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock);
- }
- public function testInstanceOf()
- {
- $model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock);
- $this->assertInstanceOf(\Magento\Sales\Model\Config::class, $model);
- }
- public function testGetTotalsRenderer()
- {
- $areaCode = 'frontend';
- $section = 'config';
- $group = 'sales';
- $code = 'payment';
- $path = $section . '/' . $group . '/' . $code . '/' . 'renderers' . '/' . $areaCode;
- $expected = ['test data'];
- $this->stateMock->expects($this->once())
- ->method('getAreaCode')
- ->will($this->returnValue($areaCode));
- $this->configDataMock->expects($this->once())
- ->method('get')
- ->with($this->equalTo($path))
- ->will($this->returnValue($expected));
- $result = $this->model->getTotalsRenderer($section, $group, $code);
- $this->assertEquals($expected, $result);
- }
- public function testGetGroupTotals()
- {
- $section = 'config';
- $group = 'payment';
- $expected = ['test data'];
- $path = $section . '/' . $group;
- $this->configDataMock->expects($this->once())
- ->method('get')
- ->with($this->equalTo($path))
- ->will($this->returnValue($expected));
- $result = $this->model->getGroupTotals($section, $group);
- $this->assertEquals($expected, $result);
- }
- public function testGetAvailableProductTypes()
- {
- $productTypes = ['simple'];
- $this->configDataMock->expects($this->once())
- ->method('get')
- ->with($this->equalTo('order/available_product_types'))
- ->will($this->returnValue($productTypes));
- $result = $this->model->getAvailableProductTypes();
- $this->assertEquals($productTypes, $result);
- }
- }
|