ConfigTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Wishlist\Test\Unit\Model;
  7. use \Magento\Wishlist\Model\Config;
  8. class ConfigTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Wishlist\Model\Config
  12. */
  13. protected $model;
  14. /**
  15. * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $_scopeConfig;
  18. /**
  19. * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $_catalogConfig;
  22. /**
  23. * @var \Magento\Catalog\Model\Attribute\Config|\PHPUnit_Framework_MockObject_MockObject
  24. */
  25. protected $_attributeConfig;
  26. protected function setUp()
  27. {
  28. $this->_scopeConfig = $this->getMockBuilder(
  29. \Magento\Framework\App\Config\ScopeConfigInterface::class
  30. )->getMock();
  31. $this->_catalogConfig = $this->getMockBuilder(\Magento\Catalog\Model\Config::class)
  32. ->disableOriginalConstructor()
  33. ->getMock();
  34. $this->_attributeConfig = $this->getMockBuilder(\Magento\Catalog\Model\Attribute\Config::class)
  35. ->disableOriginalConstructor()
  36. ->getMock();
  37. $this->model = new Config($this->_scopeConfig, $this->_catalogConfig, $this->_attributeConfig);
  38. }
  39. public function testGetProductAttributes()
  40. {
  41. $expectedResult = ['attribute_one', 'attribute_two', 'attribute_three'];
  42. $this->_catalogConfig->expects($this->once())
  43. ->method('getProductAttributes')
  44. ->willReturn(['attribute_one', 'attribute_two']);
  45. $this->_attributeConfig->expects($this->once())
  46. ->method('getAttributeNames')
  47. ->with('wishlist_item')
  48. ->willReturn(['attribute_three']);
  49. $this->assertEquals($expectedResult, $this->model->getProductAttributes());
  50. }
  51. public function testGetSharingEmailLimit()
  52. {
  53. $this->assertEquals(Config::SHARING_EMAIL_LIMIT, $this->model->getSharingEmailLimit());
  54. }
  55. public function testGetSharingTextLimit()
  56. {
  57. $this->assertEquals(Config::SHARING_TEXT_LIMIT, $this->model->getSharingTextLimit());
  58. }
  59. }