21 private $assetRepoMock;
26 private $directoryListMock;
31 private $driverFileMock;
35 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
36 $this->assetRepoMock = $this->createMock(\
Magento\Framework\View\Asset\Repository::class);
37 $this->directoryListMock = $this->createMock(\
Magento\Framework\
App\Filesystem\DirectoryList::class);
38 $this->driverFileMock = $this->createMock(\
Magento\Framework\Filesystem\Driver\File::class);
41 \
Magento\Translation\Model\FileManager::class,
43 'assetRepo' => $this->assetRepoMock,
44 'directoryList' => $this->directoryListMock,
45 'driverFile' => $this->driverFileMock,
52 $path =
'relative path';
54 $fileMock = $this->createMock(\
Magento\Framework\View\Asset\File::class);
55 $contextMock = $this->getMockForAbstractClass(
56 \
Magento\Framework\View\Asset\ContextInterface::class,
64 $this->assetRepoMock->expects($this->once())->method(
'getStaticViewFileContext')->willReturn($contextMock);
65 $contextMock->expects($this->once())->method(
'getPath')->willReturn(
$path);
67 ->expects($this->once())
68 ->method(
'createArbitrary')
69 ->with($expectedPath,
'')
70 ->willReturn($fileMock);
72 $this->assertSame($fileMock, $this->model->createTranslateConfigAsset());
78 $contextMock = $this->getMockForAbstractClass(
79 \
Magento\Framework\View\Asset\ContextInterface::class,
87 $this->assetRepoMock->expects($this->atLeastOnce())
88 ->method(
'getStaticViewFileContext')
89 ->willReturn($contextMock);
90 $contextMock->expects($this->atLeastOnce())->method(
'getPath')->willReturn(
$path);
91 $this->directoryListMock->expects($this->atLeastOnce())->method(
'getPath')->willReturn(
$path);
92 $this->driverFileMock->expects($this->once())
94 ->with(
'path/path/js-translation.json')
96 $this->driverFileMock->expects($this->once())->method(
'stat')->willReturn([
'mtime' => 1445736974]);
97 $this->assertEquals(1445736974, $this->model->getTranslationFileTimestamp());
103 $contextMock = $this->getMockForAbstractClass(
104 \
Magento\Framework\View\Asset\ContextInterface::class,
112 $this->assetRepoMock->expects($this->atLeastOnce())
113 ->method(
'getStaticViewFileContext')
114 ->willReturn($contextMock);
115 $contextMock->expects($this->atLeastOnce())->method(
'getPath')->willReturn(
$path);
116 $this->assertEquals(
$path, $this->model->getTranslationFilePath());
testCreateTranslateConfigAsset()
testGetTranslationFileTimestamp()
testGetTranslationFilePath()
const TRANSLATION_CONFIG_FILE_NAME