ConfigTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Js;
  7. use Magento\Translation\Model\Js\Config;
  8. class ConfigTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var Config
  12. */
  13. protected $model;
  14. /**
  15. * @var \PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $scopeMock;
  18. /**
  19. * @var string
  20. */
  21. protected $patterns = ['test_pattern'];
  22. protected function setUp()
  23. {
  24. $this->scopeMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
  25. ->disableOriginalConstructor()
  26. ->getMock();
  27. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  28. $this->model = $objectManager->getObject(
  29. \Magento\Translation\Model\Js\Config::class,
  30. [
  31. 'scopeConfig' => $this->scopeMock,
  32. 'patterns' => $this->patterns
  33. ]
  34. );
  35. }
  36. public function testIsEmbeddedStrategy()
  37. {
  38. $this->scopeMock->expects($this->once())
  39. ->method('getValue')
  40. ->with(Config::XML_PATH_STRATEGY)
  41. ->willReturn(Config::EMBEDDED_STRATEGY);
  42. $this->assertTrue($this->model->isEmbeddedStrategy());
  43. }
  44. public function testDictionaryEnabled()
  45. {
  46. $this->scopeMock->expects($this->once())
  47. ->method('getValue')
  48. ->with(Config::XML_PATH_STRATEGY)
  49. ->willReturn(Config::DICTIONARY_STRATEGY);
  50. $this->assertTrue($this->model->dictionaryEnabled());
  51. }
  52. public function testGetPatterns()
  53. {
  54. $this->assertEquals($this->patterns, $this->model->getPatterns());
  55. }
  56. }