Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SymlinkTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink;
10 
13 
14 class SymlinkTest extends \PHPUnit\Framework\TestCase
15 {
19  private $symlinkPublisher;
20 
21  protected function setUp()
22  {
23  $this->symlinkPublisher = new Symlink;
24  }
25 
26  public function testPublishFile()
27  {
28  $rootDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class)
29  ->getMock();
30  $targetDir = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class)
31  ->getMock();
32  $sourcePath = 'source/path/file';
33  $destinationPath = 'destination/path/file';
34 
35  $rootDir->expects($this->once())
36  ->method('createSymlink')
37  ->with(
38  $sourcePath,
39  $destinationPath,
40  $targetDir
41  )->willReturn(true);
42 
43  $this->assertTrue($this->symlinkPublisher->publishFile($rootDir, $targetDir, $sourcePath, $destinationPath));
44  }
45 
49  public function testIsSupported($path, $expectation)
50  {
51  $asset = $this->getMockBuilder(\Magento\Framework\View\Asset\LocalInterface::class)
52  ->setMethods([])
53  ->getMock();
54  $asset->expects($this->once())
55  ->method('getSourceFile')
56  ->willReturn($path);
57  $this->assertEquals($expectation, $this->symlinkPublisher->isSupported($asset));
58  }
59 
63  public function sourceFileDataProvider()
64  {
65  return [
66  ['path/to/file', true],
67  [DirectoryList::TMP_MATERIALIZATION_DIR . '/path/to/file', false]
68  ];
69  }
70 }
$rootDir
Definition: website.php:12