Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WeeeConfigProviderTest.php
Go to the documentation of this file.
1 <?php
7 
8 class WeeeConfigProviderTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $weeeHelperMock;
14 
18  protected $weeeConfigMock;
19 
23  protected $storeManagerMock;
24 
28  protected $storeMock;
29 
33  protected $model;
34 
35  protected function setUp()
36  {
37  $this->weeeHelperMock = $this->createMock(\Magento\Weee\Helper\Data::class);
38  $this->weeeConfigMock = $this->createMock(\Magento\Weee\Model\Config::class);
39  $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
40  $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class);
41 
42  $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
43 
44  $this->model = new \Magento\Weee\Model\WeeeConfigProvider(
45  $this->weeeHelperMock,
46  $this->storeManagerMock,
47  $this->weeeConfigMock
48  );
49  }
50 
59  public function testGetConfig(
60  $expectedResult,
61  $weeeHelperEnabled,
62  $displayWeeeDetails,
63  $weeeConfigEnabled,
64  $includeInSubtotal
65  ) {
66  $storeId = 1;
67  $this->storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
68  $this->weeeHelperMock->expects($this->any())->method('isEnabled')->with($storeId)
69  ->will($this->returnValue($weeeHelperEnabled));
70  $this->weeeHelperMock->expects($this->any())->method('typeOfDisplay')
71  ->will($this->returnValue($displayWeeeDetails));
72 
73  $this->weeeConfigMock->expects($this->any())->method('isEnabled')
74  ->will($this->returnValue($weeeConfigEnabled));
75  $this->weeeConfigMock->expects($this->any())->method('includeInSubtotal')
76  ->will($this->returnValue($includeInSubtotal));
77 
78  $this->assertEquals($expectedResult, $this->model->getConfig());
79  }
80 
84  public function getConfigDataProvider()
85  {
86  return [
87  [
88  'expectedResult' => [
89  'isDisplayPriceWithWeeeDetails' => false,
90  'isDisplayFinalPrice' => true,
91  'isWeeeEnabled' => false,
92  'isIncludedInSubtotal' => true,
93  'getIncludeWeeeFlag' => true,
94  ],
95  'weeeHelperEnabled' => false,
96  'displayWeeeDetails' => true,
97  'weeeConfigEnabled' => true,
98  'includeInSubtotal' => true,
99  ],
100  [
101  'expectedResult' => [
102  'isDisplayPriceWithWeeeDetails' => true,
103  'isDisplayFinalPrice' => true,
104  'isWeeeEnabled' => true,
105  'isIncludedInSubtotal' => true,
106  'getIncludeWeeeFlag' => true,
107  ],
108  'weeeHelperEnabled' => true,
109  'displayWeeeDetails' => true,
110  'weeeConfigEnabled' => true,
111  'includeInSubtotal' => true,
112  ],
113  [
114  'expectedResult' => [
115  'isDisplayPriceWithWeeeDetails' => false,
116  'isDisplayFinalPrice' => false,
117  'isWeeeEnabled' => true,
118  'isIncludedInSubtotal' => true,
119  'getIncludeWeeeFlag' => false,
120  ],
121  'weeeHelperEnabled' => true,
122  'displayWeeeDetails' => false,
123  'weeeConfigEnabled' => true,
124  'includeInSubtotal' => true,
125  ],
126  [
127  'expectedResult' => [
128  'isDisplayPriceWithWeeeDetails' => false,
129  'isDisplayFinalPrice' => false,
130  'isWeeeEnabled' => false,
131  'isIncludedInSubtotal' => true,
132  'getIncludeWeeeFlag' => false,
133  ],
134  'weeeHelperEnabled' => false,
135  'displayWeeeDetails' => false,
136  'weeeConfigEnabled' => true,
137  'includeInSubtotal' => true,
138  ],
139  [
140  'expectedResult' => [
141  'isDisplayPriceWithWeeeDetails' => false,
142  'isDisplayFinalPrice' => false,
143  'isWeeeEnabled' => false,
144  'isIncludedInSubtotal' => false,
145  'getIncludeWeeeFlag' => false,
146  ],
147  'weeeHelperEnabled' => false,
148  'displayWeeeDetails' => false,
149  'weeeConfigEnabled' => false,
150  'includeInSubtotal' => true,
151  ],
152  [
153  'expectedResult' => [
154  'isDisplayPriceWithWeeeDetails' => false,
155  'isDisplayFinalPrice' => false,
156  'isWeeeEnabled' => false,
157  'isIncludedInSubtotal' => false,
158  'getIncludeWeeeFlag' => false,
159  ],
160  'weeeHelperEnabled' => false,
161  'displayWeeeDetails' => false,
162  'weeeConfigEnabled' => true,
163  'includeInSubtotal' => false,
164  ],
165  [
166  'expectedResult' => [
167  'isDisplayPriceWithWeeeDetails' => false,
168  'isDisplayFinalPrice' => false,
169  'isWeeeEnabled' => false,
170  'isIncludedInSubtotal' => false,
171  'getIncludeWeeeFlag' => false,
172  ],
173  'weeeHelperEnabled' => false,
174  'displayWeeeDetails' => false,
175  'weeeConfigEnabled' => false,
176  'includeInSubtotal' => false,
177  ],
178  ];
179  }
180 }
testGetConfig( $expectedResult, $weeeHelperEnabled, $displayWeeeDetails, $weeeConfigEnabled, $includeInSubtotal)