ConfigTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Test\Unit\Model;
  7. class ConfigTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Sales\Model\Config
  11. */
  12. protected $model;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $configDataMock;
  17. /**
  18. * @var \PHPUnit_Framework_MockObject_MockObject
  19. */
  20. protected $stateMock;
  21. protected function setUp()
  22. {
  23. $this->configDataMock = $this->getMockBuilder(\Magento\Sales\Model\Config\Data::class)
  24. ->disableOriginalConstructor()
  25. ->getMock();
  26. $this->stateMock = $this->getMockBuilder(\Magento\Framework\App\State::class)
  27. ->disableOriginalConstructor()
  28. ->getMock();
  29. $this->model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock);
  30. }
  31. public function testInstanceOf()
  32. {
  33. $model = new \Magento\Sales\Model\Config($this->configDataMock, $this->stateMock);
  34. $this->assertInstanceOf(\Magento\Sales\Model\Config::class, $model);
  35. }
  36. public function testGetTotalsRenderer()
  37. {
  38. $areaCode = 'frontend';
  39. $section = 'config';
  40. $group = 'sales';
  41. $code = 'payment';
  42. $path = $section . '/' . $group . '/' . $code . '/' . 'renderers' . '/' . $areaCode;
  43. $expected = ['test data'];
  44. $this->stateMock->expects($this->once())
  45. ->method('getAreaCode')
  46. ->will($this->returnValue($areaCode));
  47. $this->configDataMock->expects($this->once())
  48. ->method('get')
  49. ->with($this->equalTo($path))
  50. ->will($this->returnValue($expected));
  51. $result = $this->model->getTotalsRenderer($section, $group, $code);
  52. $this->assertEquals($expected, $result);
  53. }
  54. public function testGetGroupTotals()
  55. {
  56. $section = 'config';
  57. $group = 'payment';
  58. $expected = ['test data'];
  59. $path = $section . '/' . $group;
  60. $this->configDataMock->expects($this->once())
  61. ->method('get')
  62. ->with($this->equalTo($path))
  63. ->will($this->returnValue($expected));
  64. $result = $this->model->getGroupTotals($section, $group);
  65. $this->assertEquals($expected, $result);
  66. }
  67. public function testGetAvailableProductTypes()
  68. {
  69. $productTypes = ['simple'];
  70. $this->configDataMock->expects($this->once())
  71. ->method('get')
  72. ->with($this->equalTo('order/available_product_types'))
  73. ->will($this->returnValue($productTypes));
  74. $result = $this->model->getAvailableProductTypes();
  75. $this->assertEquals($productTypes, $result);
  76. }
  77. }