ConfigTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Cache\Test\Unit;
  7. class ConfigTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\Cache\Config\Data|\PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $_storage;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Cache\Config
  15. */
  16. protected $_model;
  17. protected function setUp()
  18. {
  19. $this->_storage = $this->createPartialMock(\Magento\Framework\Cache\Config\Data::class, ['get']);
  20. $this->_model = new \Magento\Framework\Cache\Config($this->_storage);
  21. }
  22. public function testGetTypes()
  23. {
  24. $this->_storage->expects(
  25. $this->once()
  26. )->method(
  27. 'get'
  28. )->with(
  29. 'types',
  30. []
  31. )->will(
  32. $this->returnValue(['val1', 'val2'])
  33. );
  34. $result = $this->_model->getTypes();
  35. $this->assertCount(2, $result);
  36. }
  37. public function testGetType()
  38. {
  39. $this->_storage->expects(
  40. $this->once()
  41. )->method(
  42. 'get'
  43. )->with(
  44. 'types/someType',
  45. []
  46. )->will(
  47. $this->returnValue(['someTypeValue'])
  48. );
  49. $result = $this->_model->getType('someType');
  50. $this->assertCount(1, $result);
  51. }
  52. }