/** * @return void */ protected function _construct() { parent::_construct(); $type = $this->_getMediaType(); $allowed = $this->_imagesStorage->getAllowedExtensions($type); $labels = array(); $files = array(); foreach ($allowed as $ext) { $labels[] = '.' . $ext; $files[] = '*.' . $ext; } $this->getConfig()->setUrl($this->_urlBuilder->addSessionParam()->getUrl('cms/*/upload', array('type' => $type)))->setFileField('image')->setFilters(array('images' => array('label' => __('Images (%1)', implode(', ', $labels)), 'files' => $files))); }
/** * 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); }
/** * Get image height * * @return int */ public function getImagesHeight() { return $this->_imageStorage->getResizeHeight(); }
/** * @covers \Magento\Cms\Model\Wysiwyg\Images\Storage::deleteDirectory */ public function testDeleteRootDirectory() { $this->setExpectedException('\\Magento\\Framework\\Exception\\LocalizedException', sprintf('We cannot delete root directory %s.', self::STORAGE_ROOT_DIR)); $this->_model->deleteDirectory(self::STORAGE_ROOT_DIR); }