DataTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Test\Unit\Config;
  7. class DataTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\App\Config\Data
  11. */
  12. protected $_model;
  13. /**
  14. * @var \Magento\Framework\App\Config\MetadataProcessor|\PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $_metaDataProcessor;
  17. protected function setUp()
  18. {
  19. $this->_metaDataProcessor = $this->createMock(\Magento\Framework\App\Config\MetadataProcessor::class);
  20. $this->_metaDataProcessor->expects($this->any())->method('process')->will($this->returnArgument(0));
  21. $this->_model = new \Magento\Framework\App\Config\Data($this->_metaDataProcessor, []);
  22. }
  23. /**
  24. * @param string $path
  25. * @param mixed $value
  26. * @dataProvider setValueDataProvider
  27. */
  28. public function testSetValue($path, $value)
  29. {
  30. $this->_model->setValue($path, $value);
  31. $this->assertEquals($value, $this->_model->getValue($path));
  32. }
  33. /**
  34. * @return array
  35. */
  36. public function setValueDataProvider()
  37. {
  38. return [
  39. 'simple value' => ['some/config/value', 'test'],
  40. 'complex value' => ['some/config/value', ['level1' => ['level2' => 'test']]]
  41. ];
  42. }
  43. public function testGetData()
  44. {
  45. $model = new \Magento\Framework\App\Config\Data(
  46. $this->_metaDataProcessor,
  47. ['test' => ['path' => 'value']]
  48. );
  49. $this->assertEquals('value', $model->getValue('test/path'));
  50. }
  51. }