Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class DataTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $helper;
18 
22  protected $filesystem;
23 
24  protected function setUp()
25  {
26  $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class)->disableOriginalConstructor()
27  ->getMock();
28 
29  $this->filesystem->expects($this->any())
30  ->method('getDirectoryRead')
31  ->will($this->returnCallback(function ($code) {
32  $dir = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class);
33  $dir->expects($this->any())
34  ->method('getAbsolutePath')
35  ->will($this->returnCallback(function ($path) use ($code) {
36  $path = empty($path) ? $path : '/' . $path;
37  return rtrim($code, '/') . $path;
38  }));
39  return $dir;
40  }));
41 
42  $this->helper = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
43  ->getObject(
44  \Magento\Backup\Helper\Data::class,
45  ['filesystem' => $this->filesystem]
46  );
47  }
48 
49  public function testGetBackupIgnorePaths()
50  {
51  $this->assertEquals(
52  [
53  '.git',
54  '.svn',
59  DirectoryList::VAR_DIR . '/full_page_cache',
60  DirectoryList::VAR_DIR . '/locks',
61  DirectoryList::VAR_DIR . '/report',
62  ],
63  $this->helper->getBackupIgnorePaths()
64  );
65  }
66 
67  public function testGetRollbackIgnorePaths()
68  {
69  $this->assertEquals(
70  [
71  '.svn',
72  '.git',
76  DirectoryList::VAR_DIR . '/locks',
77  DirectoryList::VAR_DIR . '/report',
78  DirectoryList::ROOT . '/errors',
79  DirectoryList::ROOT . '/index.php',
80  ],
81  $this->helper->getRollbackIgnorePaths()
82  );
83  }
84 }
$code
Definition: info.phtml:12