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
11 
12 use \Magento\Tax\Model\Config;
13 
14 class ConfigTest extends \PHPUnit\Framework\TestCase
15 {
24  public function testDirectSettersGettersMethods($setterMethod, $getterMethod, $value)
25  {
26  // Need a mocked object with only dummy methods. It is just needed for construction.
27  // The setter/getter methods do not use this object (for this set of tests).
28  $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
29 
31  $model = new Config($scopeConfigMock);
32  $model->{$setterMethod}($value);
33  $this->assertEquals($value, $model->{$getterMethod}());
34  }
35 
40  {
41  return [
42  ['setShippingPriceIncludeTax', 'shippingPriceIncludesTax', true],
43  ['setShippingPriceIncludeTax', 'shippingPriceIncludesTax', false],
44  ['setNeedUseShippingExcludeTax', 'getNeedUseShippingExcludeTax', true],
45  ['setNeedUseShippingExcludeTax', 'getNeedUseShippingExcludeTax', false],
46  ['setPriceIncludesTax', 'priceIncludesTax', true],
47  ['setPriceIncludesTax', 'priceIncludesTax', false],
48  ['setPriceIncludesTax', 'priceIncludesTax', null]
49  ];
50  }
51 
60  public function testGetCalculationSequence($applyTaxAfterDiscount, $discountTaxIncl, $expectedValue)
61  {
62  $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
63  $scopeConfigMock->expects($this->at(0))
64  ->method('getValue')
65  ->will($this->returnValue($applyTaxAfterDiscount));
66  $scopeConfigMock->expects($this->at(1))
67  ->method('getValue')
68  ->will($this->returnValue($discountTaxIncl));
69 
71  $model = new Config($scopeConfigMock);
72  $this->assertEquals($expectedValue, $model->getCalculationSequence());
73  }
74 
79  {
80  return [
85  ];
86  }
87 
97  public function testScopeConfigMethods($method, $path, $configValue, $expectedValue)
98  {
99  $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
100  $scopeConfigMock->expects($this->once())
101  ->method('getValue')
102  ->with($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)
103  ->will($this->returnValue($configValue));
104 
106  $model = new Config($scopeConfigMock);
107  $this->assertEquals($expectedValue, $model->{$method}());
108  }
109 
115  {
116  return [
117  [
118  'priceIncludesTax',
119  Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX,
120  true,
121  true,
122  ],
123  [
124  'applyTaxAfterDiscount',
125  Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT,
126  true,
127  true
128  ],
129  [
130  'getPriceDisplayType',
131  Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE,
132  true,
133  true
134  ],
135  [
136  'discountTax',
137  Config::CONFIG_XML_PATH_DISCOUNT_TAX,
138  1,
139  true
140  ],
141  [
142  'getAlgorithm',
143  Config::XML_PATH_ALGORITHM,
144  true,
145  true
146  ],
147  [
148  'getShippingTaxClass',
149  Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
150  true,
151  true
152  ],
153  [
154  'getShippingPriceDisplayType',
155  Config::CONFIG_XML_PATH_DISPLAY_SHIPPING,
156  true,
157  true
158  ],
159  [
160  'shippingPriceIncludesTax',
161  Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX,
162  true,
163  true
164  ],
165  [
166  'displayCartPricesInclTax',
167  Config::XML_PATH_DISPLAY_CART_PRICE,
168  Config::DISPLAY_TYPE_INCLUDING_TAX,
169  true
170  ],
171  [
172  'displayCartPricesExclTax',
173  Config::XML_PATH_DISPLAY_CART_PRICE,
174  Config::DISPLAY_TYPE_EXCLUDING_TAX,
175  true
176  ],
177  [
178  'displayCartPricesBoth',
179  Config::XML_PATH_DISPLAY_CART_PRICE,
180  Config::DISPLAY_TYPE_BOTH,
181  true
182  ],
183  [
184  'displayCartSubtotalInclTax',
185  Config::XML_PATH_DISPLAY_CART_SUBTOTAL,
186  Config::DISPLAY_TYPE_INCLUDING_TAX,
187  true
188  ],
189  [
190  'displayCartSubtotalExclTax',
191  Config::XML_PATH_DISPLAY_CART_SUBTOTAL,
192  Config::DISPLAY_TYPE_EXCLUDING_TAX,
193  true
194  ],
195  [
196  'displayCartSubtotalBoth',
197  Config::XML_PATH_DISPLAY_CART_SUBTOTAL,
198  Config::DISPLAY_TYPE_BOTH,
199  true
200  ],
201  [
202  'displayCartShippingInclTax',
203  Config::XML_PATH_DISPLAY_CART_SHIPPING,
204  Config::DISPLAY_TYPE_INCLUDING_TAX,
205  true
206  ],
207  [
208  'displayCartShippingExclTax',
209  Config::XML_PATH_DISPLAY_CART_SHIPPING,
210  Config::DISPLAY_TYPE_EXCLUDING_TAX,
211  true
212  ],
213  [
214  'displayCartShippingBoth',
215  Config::XML_PATH_DISPLAY_CART_SHIPPING,
216  Config::DISPLAY_TYPE_BOTH,
217  true
218  ],
219  [
220  'displayCartDiscountInclTax',
221  Config::XML_PATH_DISPLAY_CART_DISCOUNT,
222  Config::DISPLAY_TYPE_INCLUDING_TAX,
223  true
224  ],
225  [
226  'displayCartDiscountExclTax',
227  Config::XML_PATH_DISPLAY_CART_DISCOUNT,
228  Config::DISPLAY_TYPE_EXCLUDING_TAX,
229  true
230  ],
231  [
232  'displayCartDiscountBoth',
233  Config::XML_PATH_DISPLAY_CART_DISCOUNT,
234  Config::DISPLAY_TYPE_BOTH,
235  true
236  ],
237  [
238  'displayCartTaxWithGrandTotal',
239  Config::XML_PATH_DISPLAY_CART_GRANDTOTAL,
240  true,
241  true
242  ],
243  [
244  'displayCartFullSummary',
245  Config::XML_PATH_DISPLAY_CART_FULL_SUMMARY,
246  true,
247  true
248  ],
249  [
250  'displayCartZeroTax',
251  Config::XML_PATH_DISPLAY_CART_ZERO_TAX,
252  true,
253  true
254  ],
255  [
256  'displaySalesPricesInclTax',
257  Config::XML_PATH_DISPLAY_SALES_PRICE,
258  Config::DISPLAY_TYPE_INCLUDING_TAX,
259  true
260  ],
261  [
262  'displaySalesPricesExclTax',
263  Config::XML_PATH_DISPLAY_SALES_PRICE,
264  Config::DISPLAY_TYPE_EXCLUDING_TAX,
265  true
266  ],
267  [
268  'displaySalesPricesBoth',
269  Config::XML_PATH_DISPLAY_SALES_PRICE,
270  Config::DISPLAY_TYPE_BOTH,
271  true
272  ],
273  [
274  'displaySalesSubtotalInclTax',
275  Config::XML_PATH_DISPLAY_SALES_SUBTOTAL,
276  Config::DISPLAY_TYPE_INCLUDING_TAX,
277  true
278  ],
279  [
280  'displaySalesSubtotalExclTax',
281  Config::XML_PATH_DISPLAY_SALES_SUBTOTAL,
282  Config::DISPLAY_TYPE_EXCLUDING_TAX,
283  true
284  ],
285  [
286  'displaySalesSubtotalBoth',
287  Config::XML_PATH_DISPLAY_SALES_SUBTOTAL,
288  Config::DISPLAY_TYPE_BOTH,
289  true
290  ],
291  [
292  'displaySalesShippingInclTax',
293  Config::XML_PATH_DISPLAY_SALES_SHIPPING,
294  Config::DISPLAY_TYPE_INCLUDING_TAX,
295  true
296  ],
297  [
298  'displaySalesShippingExclTax',
299  Config::XML_PATH_DISPLAY_SALES_SHIPPING,
300  Config::DISPLAY_TYPE_EXCLUDING_TAX,
301  true
302  ],
303  [
304  'displaySalesShippingBoth',
305  Config::XML_PATH_DISPLAY_SALES_SHIPPING,
306  Config::DISPLAY_TYPE_BOTH,
307  true
308  ],
309  [
310  'displaySalesDiscountInclTax',
311  Config::XML_PATH_DISPLAY_SALES_DISCOUNT,
312  Config::DISPLAY_TYPE_INCLUDING_TAX,
313  true
314  ],
315  [
316  'displaySalesDiscountExclTax',
317  Config::XML_PATH_DISPLAY_SALES_DISCOUNT,
318  Config::DISPLAY_TYPE_EXCLUDING_TAX,
319  true
320  ],
321  [
322  'displaySalesDiscountBoth',
323  Config::XML_PATH_DISPLAY_SALES_DISCOUNT,
324  Config::DISPLAY_TYPE_BOTH,
325  true
326  ],
327  [
328  'displaySalesTaxWithGrandTotal',
329  Config::XML_PATH_DISPLAY_SALES_GRANDTOTAL,
330  true,
331  true
332  ],
333  [
334  'displaySalesFullSummary',
335  Config::XML_PATH_DISPLAY_SALES_FULL_SUMMARY,
336  true,
337  true
338  ],
339  [
340  'displaySalesZeroTax',
341  Config::XML_PATH_DISPLAY_SALES_ZERO_TAX,
342  true,
343  true
344  ],
345  [
346  'crossBorderTradeEnabled',
347  Config::CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED,
348  true,
349  true
350  ],
351  [
352  'isWrongDisplaySettingsIgnored',
353  Config::XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY,
354  true,
355  true
356  ],
357  [
358  'isWrongDiscountSettingsIgnored',
359  Config::XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT,
360  true,
361  true
362  ],
363  [
364  'isWrongApplyDiscountSettingIgnored',
365  Config::XML_PATH_TAX_NOTIFICATION_IGNORE_APPLY_DISCOUNT,
366  true,
367  true
368  ],
369  [
370  'getInfoUrl',
371  Config::XML_PATH_TAX_NOTIFICATION_INFO_URL,
372  'http:\\kiwis.rule.com',
373  'http:\\kiwis.rule.com'
374  ]
375  ];
376  }
377 }
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13