ConfigTest.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Test class for \Magento\Weee\Model\Config
  8. */
  9. namespace Magento\Weee\Test\Unit\Model;
  10. use \Magento\Weee\Model\Config;
  11. class ConfigTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * Tests the methods that rely on the ScopeConfigInterface object to provide their return values
  15. *
  16. * @param string $method
  17. * @param string $path
  18. * @param bool $configValue
  19. * @param bool $expectedValue
  20. * @dataProvider dataProviderScopeConfigMethods
  21. */
  22. public function testScopeConfigMethods($method, $path, $configValue, $expectedValue)
  23. {
  24. $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class);
  25. $scopeConfigMock->expects($this->any())
  26. ->method('getValue')
  27. ->with($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)
  28. ->will($this->returnValue($configValue));
  29. $scopeConfigMock->expects($this->any())
  30. ->method('isSetFlag')
  31. ->with($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)
  32. ->will($this->returnValue($configValue));
  33. $taxData = $this->createMock(\Magento\Tax\Helper\Data::class);
  34. /** @var \Magento\Weee\Model\Config */
  35. $model = new Config($scopeConfigMock, $taxData);
  36. $this->assertEquals($expectedValue, $model->{$method}());
  37. }
  38. /**
  39. * @return array
  40. * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  41. */
  42. public function dataProviderScopeConfigMethods()
  43. {
  44. return [
  45. [
  46. 'getPriceDisplayType',
  47. Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW,
  48. true,
  49. true,
  50. ],
  51. [
  52. 'getListPriceDisplayType',
  53. Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST,
  54. true,
  55. true
  56. ],
  57. [
  58. 'getSalesPriceDisplayType',
  59. Config::XML_PATH_FPT_DISPLAY_SALES,
  60. true,
  61. true
  62. ],
  63. [
  64. 'getEmailPriceDisplayType',
  65. Config::XML_PATH_FPT_DISPLAY_EMAIL,
  66. true,
  67. true
  68. ],
  69. [
  70. 'includeInSubtotal',
  71. Config::XML_PATH_FPT_INCLUDE_IN_SUBTOTAL,
  72. true,
  73. true
  74. ],
  75. [
  76. 'isTaxable',
  77. Config::XML_PATH_FPT_TAXABLE,
  78. true,
  79. true
  80. ],
  81. [
  82. 'isEnabled',
  83. Config::XML_PATH_FPT_ENABLED,
  84. true,
  85. true
  86. ]
  87. ];
  88. }
  89. }