WeeeConfigProviderTest.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Weee\Test\Unit\Model;
  7. class WeeeConfigProviderTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $weeeHelperMock;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $weeeConfigMock;
  17. /**
  18. * @var \PHPUnit_Framework_MockObject_MockObject
  19. */
  20. protected $storeManagerMock;
  21. /**
  22. * @var \PHPUnit_Framework_MockObject_MockObject
  23. */
  24. protected $storeMock;
  25. /**
  26. * @var \Magento\Weee\Model\WeeeConfigProvider
  27. */
  28. protected $model;
  29. protected function setUp()
  30. {
  31. $this->weeeHelperMock = $this->createMock(\Magento\Weee\Helper\Data::class);
  32. $this->weeeConfigMock = $this->createMock(\Magento\Weee\Model\Config::class);
  33. $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
  34. $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class);
  35. $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
  36. $this->model = new \Magento\Weee\Model\WeeeConfigProvider(
  37. $this->weeeHelperMock,
  38. $this->storeManagerMock,
  39. $this->weeeConfigMock
  40. );
  41. }
  42. /**
  43. * @dataProvider getConfigDataProvider
  44. * @param array $expectedResult
  45. * @param bool $weeeHelperEnabled
  46. * @param bool $displayWeeeDetails
  47. * @param bool $weeeConfigEnabled
  48. * @param bool $includeInSubtotal
  49. */
  50. public function testGetConfig(
  51. $expectedResult,
  52. $weeeHelperEnabled,
  53. $displayWeeeDetails,
  54. $weeeConfigEnabled,
  55. $includeInSubtotal
  56. ) {
  57. $storeId = 1;
  58. $this->storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
  59. $this->weeeHelperMock->expects($this->any())->method('isEnabled')->with($storeId)
  60. ->will($this->returnValue($weeeHelperEnabled));
  61. $this->weeeHelperMock->expects($this->any())->method('typeOfDisplay')
  62. ->will($this->returnValue($displayWeeeDetails));
  63. $this->weeeConfigMock->expects($this->any())->method('isEnabled')
  64. ->will($this->returnValue($weeeConfigEnabled));
  65. $this->weeeConfigMock->expects($this->any())->method('includeInSubtotal')
  66. ->will($this->returnValue($includeInSubtotal));
  67. $this->assertEquals($expectedResult, $this->model->getConfig());
  68. }
  69. /**
  70. * @return array
  71. */
  72. public function getConfigDataProvider()
  73. {
  74. return [
  75. [
  76. 'expectedResult' => [
  77. 'isDisplayPriceWithWeeeDetails' => false,
  78. 'isDisplayFinalPrice' => true,
  79. 'isWeeeEnabled' => false,
  80. 'isIncludedInSubtotal' => true,
  81. 'getIncludeWeeeFlag' => true,
  82. ],
  83. 'weeeHelperEnabled' => false,
  84. 'displayWeeeDetails' => true,
  85. 'weeeConfigEnabled' => true,
  86. 'includeInSubtotal' => true,
  87. ],
  88. [
  89. 'expectedResult' => [
  90. 'isDisplayPriceWithWeeeDetails' => true,
  91. 'isDisplayFinalPrice' => true,
  92. 'isWeeeEnabled' => true,
  93. 'isIncludedInSubtotal' => true,
  94. 'getIncludeWeeeFlag' => true,
  95. ],
  96. 'weeeHelperEnabled' => true,
  97. 'displayWeeeDetails' => true,
  98. 'weeeConfigEnabled' => true,
  99. 'includeInSubtotal' => true,
  100. ],
  101. [
  102. 'expectedResult' => [
  103. 'isDisplayPriceWithWeeeDetails' => false,
  104. 'isDisplayFinalPrice' => false,
  105. 'isWeeeEnabled' => true,
  106. 'isIncludedInSubtotal' => true,
  107. 'getIncludeWeeeFlag' => false,
  108. ],
  109. 'weeeHelperEnabled' => true,
  110. 'displayWeeeDetails' => false,
  111. 'weeeConfigEnabled' => true,
  112. 'includeInSubtotal' => true,
  113. ],
  114. [
  115. 'expectedResult' => [
  116. 'isDisplayPriceWithWeeeDetails' => false,
  117. 'isDisplayFinalPrice' => false,
  118. 'isWeeeEnabled' => false,
  119. 'isIncludedInSubtotal' => true,
  120. 'getIncludeWeeeFlag' => false,
  121. ],
  122. 'weeeHelperEnabled' => false,
  123. 'displayWeeeDetails' => false,
  124. 'weeeConfigEnabled' => true,
  125. 'includeInSubtotal' => true,
  126. ],
  127. [
  128. 'expectedResult' => [
  129. 'isDisplayPriceWithWeeeDetails' => false,
  130. 'isDisplayFinalPrice' => false,
  131. 'isWeeeEnabled' => false,
  132. 'isIncludedInSubtotal' => false,
  133. 'getIncludeWeeeFlag' => false,
  134. ],
  135. 'weeeHelperEnabled' => false,
  136. 'displayWeeeDetails' => false,
  137. 'weeeConfigEnabled' => false,
  138. 'includeInSubtotal' => true,
  139. ],
  140. [
  141. 'expectedResult' => [
  142. 'isDisplayPriceWithWeeeDetails' => false,
  143. 'isDisplayFinalPrice' => false,
  144. 'isWeeeEnabled' => false,
  145. 'isIncludedInSubtotal' => false,
  146. 'getIncludeWeeeFlag' => false,
  147. ],
  148. 'weeeHelperEnabled' => false,
  149. 'displayWeeeDetails' => false,
  150. 'weeeConfigEnabled' => true,
  151. 'includeInSubtotal' => false,
  152. ],
  153. [
  154. 'expectedResult' => [
  155. 'isDisplayPriceWithWeeeDetails' => false,
  156. 'isDisplayFinalPrice' => false,
  157. 'isWeeeEnabled' => false,
  158. 'isIncludedInSubtotal' => false,
  159. 'getIncludeWeeeFlag' => false,
  160. ],
  161. 'weeeHelperEnabled' => false,
  162. 'displayWeeeDetails' => false,
  163. 'weeeConfigEnabled' => false,
  164. 'includeInSubtotal' => false,
  165. ],
  166. ];
  167. }
  168. }