Пример #1
0
 /**
  * General conditions for testGetDirsCollection tests
  *
  * @param string $path
  * @param array $collectionArray
  * @param array $expectedRemoveKeys
  */
 protected function generalTestGetDirsCollection($path, $collectionArray = [], $expectedRemoveKeys = [])
 {
     /** @var StorageCollection|\PHPUnit_Framework_MockObject_MockObject $storageCollectionMock */
     $storageCollectionMock = $this->getMockBuilder('Magento\\Cms\\Model\\Wysiwyg\\Images\\Storage\\Collection')->disableOriginalConstructor()->getMock();
     $storageCollectionMock->expects($this->once())->method('setCollectDirs')->with(true)->willReturnSelf();
     $storageCollectionMock->expects($this->once())->method('setCollectFiles')->with(false)->willReturnSelf();
     $storageCollectionMock->expects($this->once())->method('setCollectRecursively')->with(false)->willReturnSelf();
     $storageCollectionMock->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator($collectionArray));
     $storageCollectionInvMock = $storageCollectionMock->expects($this->exactly(sizeof($expectedRemoveKeys)))->method('removeItemByKey');
     call_user_func_array([$storageCollectionInvMock, 'withConsecutive'], $expectedRemoveKeys);
     $this->storageCollectionFactoryMock->expects($this->once())->method('create')->willReturn($storageCollectionMock);
     $this->imagesStorage->getDirsCollection($path);
 }
Пример #2
0
 /**
  * Storage collection
  *
  * @param string $path Path to the directory
  * @return \Magento\Cms\Model\Wysiwyg\Images\Storage\Collection
  */
 public function getCollection($path = null)
 {
     /** @var \Magento\Cms\Model\Wysiwyg\Images\Storage\Collection $collection */
     $collection = $this->_storageCollectionFactory->create();
     if ($path !== null) {
         $collection->addTargetDir($path);
     }
     return $collection;
 }