Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
JsTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class JsTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $model;
16 
20  protected $configMock;
21 
25  protected $fileManagerMock;
26 
27  protected function setUp()
28  {
29  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
30  $this->configMock = $this->getMockBuilder(\Magento\Translation\Model\Js\Config::class)
31  ->disableOriginalConstructor()
32  ->getMock();
33  $this->fileManagerMock = $this->getMockBuilder(\Magento\Translation\Model\FileManager::class)
34  ->disableOriginalConstructor()
35  ->getMock();
36  $this->model = $objectManager->getObject(
37  \Magento\Translation\Block\Js::class,
38  [
39  'config' => $this->configMock,
40  'fileManager' => $this->fileManagerMock
41  ]
42  );
43  }
44 
45  public function testIsDictionaryStrategy()
46  {
47  $this->configMock->expects($this->once())
48  ->method('dictionaryEnabled')
49  ->willReturn(true);
50  $this->assertTrue($this->model->dictionaryEnabled());
51  }
52 
54  {
55  $this->fileManagerMock->expects($this->once())
56  ->method('getTranslationFileTimestamp')
57  ->willReturn(1445736974);
58  $this->assertEquals(1445736974, $this->model->getTranslationFileTimestamp());
59  }
60 
61  public function testGetTranslationFilePath()
62  {
63  $this->fileManagerMock->expects($this->once())
64  ->method('getTranslationFilePath')
65  ->willReturn('frontend/Magento/luma/en_EN');
66  $this->assertEquals('frontend/Magento/luma/en_EN', $this->model->getTranslationFilePath());
67  }
68 
70  {
71  $version = sha1('translationFile');
72 
73  $this->fileManagerMock->expects($this->once())
74  ->method('getTranslationFileVersion')
75  ->willReturn($version);
76  $this->assertEquals($version, $this->model->getTranslationFileVersion());
77  }
78 }
$objectManager
Definition: bootstrap.php:17