public function testGetCurrentStorageCode() { $currentStorage = '10'; $this->configMock->expects($this->once())->method('getValue')->with(\Magento\MediaStorage\Model\File\Storage::XML_PATH_STORAGE_MEDIA, 'default')->will($this->returnValue($currentStorage)); $this->assertEquals($currentStorage, $this->helper->getCurrentStorageCode()); $this->assertEquals($currentStorage, $this->helper->getCurrentStorageCode()); }
/** * Retrieve storage model * If storage not defined - retrieve current storage * * params = array( * connection => string, - define connection for model if needed * init => bool - force initialization process for storage model * ) * * @param int|null $storage * @param array $params * @return AbstractModel|bool */ public function getStorageModel($storage = null, $params = []) { if (is_null($storage)) { $storage = $this->_coreFileStorage->getCurrentStorageCode(); } switch ($storage) { case self::STORAGE_MEDIA_FILE_SYSTEM: $model = $this->_fileFactory->create(); break; case self::STORAGE_MEDIA_DATABASE: $connection = isset($params['connection']) ? $params['connection'] : null; $model = $this->_databaseFactory->create(['connectionName' => $connection]); break; default: return false; } if (isset($params['init']) && $params['init']) { $model->init(); } return $model; }