Example #1
0
 /**
  * test get storage data
  */
 public function testGetStorageData()
 {
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(\Magento\Framework\App\Filesystem::MEDIA_DIR))->will($this->returnValue($this->directoryReadMock));
     $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap(array(array('/', true), array('folder_one', true), array('file_three.txt', false), array('folder_one/.svn', false), array('folder_one/file_one.txt', false), array('folder_one/folder_two', true), array('folder_one/folder_two/.htaccess', false), array('folder_one/folder_two/file_two.txt', false))));
     $paths = array('folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt');
     sort($paths);
     $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths));
     $expected = array('files' => array('file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'), 'directories' => array(array('name' => 'folder_one', 'path' => '/'), array('name' => 'folder_two', 'path' => 'folder_one')));
     $actual = $this->storageFile->getStorageData();
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 /**
  * test get storage data
  */
 public function testGetStorageData()
 {
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(DirectoryList::MEDIA))->will($this->returnValue($this->directoryReadMock));
     $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap([['/', true], ['folder_one', true], ['file_three.txt', false], ['folder_one/.svn', false], ['folder_one/file_one.txt', false], ['folder_one/folder_two', true], ['folder_one/folder_two/.htaccess', false], ['folder_one/folder_two/file_two.txt', false]]));
     $paths = ['folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt'];
     sort($paths);
     $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths));
     $expected = ['files' => ['file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'], 'directories' => [['name' => 'folder_one', 'path' => '/'], ['name' => 'folder_two', 'path' => 'folder_one']]];
     $actual = $this->storageFile->getStorageData();
     $this->assertEquals($expected, $actual);
 }