ConfigTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Test\Unit\Url;
  7. class ConfigTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\View\Url\Config
  11. */
  12. protected $_model;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Config\ScopeConfigInterface
  15. */
  16. protected $_scopeConfig;
  17. protected function setUp()
  18. {
  19. $this->_scopeConfig = $this->getMockBuilder(
  20. \Magento\Framework\App\Config\ScopeConfigInterface::class
  21. )->disableOriginalConstructor()->getMock();
  22. $this->_model = new \Magento\Framework\View\Url\Config($this->_scopeConfig);
  23. }
  24. /**
  25. * @param $path
  26. * @param $expectedValue
  27. *
  28. * @dataProvider getConfigDataProvider
  29. */
  30. public function testGetValue($path, $expectedValue)
  31. {
  32. $this->_scopeConfig->expects(
  33. $this->any()
  34. )->method(
  35. 'getValue'
  36. )->with(
  37. $path
  38. )->will(
  39. $this->returnValue($expectedValue)
  40. );
  41. $actual = $this->_model->getValue($path);
  42. $this->assertEquals($expectedValue, $actual);
  43. }
  44. /**
  45. * @return array
  46. */
  47. public function getConfigDataProvider()
  48. {
  49. return [
  50. ['some/valid/path1', 'someValue'],
  51. ['some/valid/path2', 2],
  52. ['some/valid/path3', false],
  53. ['some/invalid/path3', null]
  54. ];
  55. }
  56. }