ConfigTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Translation\Test\Unit\Model\Inline;
  7. use \Magento\Translation\Model\Inline\Config;
  8. class ConfigTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var Config
  12. */
  13. protected $model;
  14. /**
  15. * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $scopeConfigMock;
  18. /**
  19. * @var \Magento\Developer\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $helperMock;
  22. protected function setUp()
  23. {
  24. $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
  25. $this->helperMock = $this->createPartialMock(\Magento\Developer\Helper\Data::class, ['isDevAllowed']);
  26. $this->model = new Config(
  27. $this->scopeConfigMock,
  28. $this->helperMock
  29. );
  30. }
  31. public function testIsActive()
  32. {
  33. $store = 'some store';
  34. $result = 'result';
  35. $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
  36. $scopeConfig->expects(
  37. $this->once()
  38. )->method(
  39. 'isSetFlag'
  40. )->with(
  41. $this->equalTo('dev/translate_inline/active'),
  42. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  43. $this->equalTo($store)
  44. )->will(
  45. $this->returnValue($result)
  46. );
  47. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  48. $config = $objectManager->getObject(
  49. \Magento\Translation\Model\Inline\Config::class,
  50. ['scopeConfig' => $scopeConfig]
  51. );
  52. $this->assertEquals($result, $config->isActive($store));
  53. }
  54. public function testIsDevAllowed()
  55. {
  56. $store = 'some store';
  57. $result = 'result';
  58. $this->helperMock->expects(
  59. $this->once()
  60. )->method(
  61. 'isDevAllowed'
  62. )->with(
  63. $store
  64. )->will(
  65. $this->returnValue($result)
  66. );
  67. $this->assertEquals($result, $this->model->isDevAllowed($store));
  68. }
  69. }