Skip to content

Commit

Permalink
fixed static tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akaplya committed Feb 20, 2020
1 parent d463494 commit e88833b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery;

use Magento\Backend\Block\DataProviders\ImageUploadConfig as ImageUploadConfigDataProvider;
use Magento\Framework\Storage\FileNotFoundException;
use Magento\Framework\App\ObjectManager;
use Magento\Backend\Block\Media\Uploader;
use Magento\Framework\Storage\StorageProvider;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Storage\FileNotFoundException;
use Magento\Framework\Storage\StorageProvider;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\MediaStorage\Helper\File\Storage\Database;

/**
Expand Down Expand Up @@ -173,6 +173,8 @@ public function getAddImagesButton()
}

/**
* Sync images to database
*
* @param string $fileName
*/
private function syncImageToDatabase(string $fileName): void
Expand All @@ -187,6 +189,8 @@ private function syncImageToDatabase(string $fileName): void
}

/**
* Returns file metadata as an associative array
*
* @param string $fileName
* @return array
* @throws FileNotFoundException
Expand Down
16 changes: 9 additions & 7 deletions app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ class Gallery extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
protected $metadata;

/**
* Gallery constructor.
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
* @param string $connectionName
* @throws \Exception
*/
* Gallery constructor.
*
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
* @param null $connectionName
* @throws \Exception
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Framework\EntityManager\MetadataPool $metadataPool,
Expand All @@ -49,7 +50,6 @@ public function __construct(
$this->metadata = $metadataPool->getMetadata(
\Magento\Catalog\Api\Data\ProductInterface::class
);

parent::__construct($context, $connectionName);
}

Expand Down Expand Up @@ -160,6 +160,8 @@ protected function createBaseLoadSelect($entityId, $storeId, $attributeId)
}

/**
* Returns media entries from database
*
* @param int $storeId
* @param array $entityIds
* @param bool $preserveSortOrder
Expand Down
21 changes: 10 additions & 11 deletions app/code/Magento/MediaStorage/Test/Unit/Service/ImageResizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
namespace Magento\MediaStorage\Test\Unit\Service;

use Magento\Catalog\Model\Product\Image\ParamsBuilder;
use Magento\Catalog\Model\View\Asset\ImageFactory as AssetImageFactory;
use Magento\Catalog\Model\Product\Media\ConfigInterface as MediaConfig;
use Magento\Catalog\Model\ResourceModel\Product\Image as ProductImage;
use Magento\Catalog\Model\View\Asset\Image as AssetImage;
use Magento\Catalog\Model\View\Asset\ImageFactory as AssetImageFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\State;
use Magento\Framework\Config\View;
use Magento\Framework\DataObject;
use Magento\Framework\Filesystem;
use Magento\Framework\Image\Factory as ImageFactory;
use Magento\Framework\Image;
use Magento\Catalog\Model\Product\Media\ConfigInterface as MediaConfig;
use Magento\Framework\App\State;
use Magento\Framework\Image\Factory as ImageFactory;
use Magento\Framework\Storage\StorageInterface;
use Magento\Framework\View\ConfigInterface as ViewConfig;
use Magento\Framework\Config\View;
use Magento\Catalog\Model\ResourceModel\Product\Image as ProductImage;
use Magento\MediaStorage\Helper\File\Storage\Database;
use Magento\MediaStorage\Service\ImageResize;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Theme\Model\Config\Customization as ThemeCustomizationConfig;
use Magento\Theme\Model\ResourceModel\Theme\Collection;
use Magento\MediaStorage\Helper\File\Storage\Database;
use Magento\Framework\App\Filesystem\DirectoryList;

/**
* Class ImageResizeTest
* Class ImageResizeTest test for \Magento\MediaStorage\Service\ImageResize
*
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -215,8 +215,7 @@ protected function setUp()
$this->viewMock->expects($this->any())
->method('getMediaEntities')
->willReturn(
['product_small_image' =>
[
['product_small_image' => [
'type' => 'small_image',
'width' => 75,
'height' => 75
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
namespace Magento\Framework\Storage;

/**
* Class FileNotFoundException
* Exception: FileNotFoundException
* Exception to be thrown when the a requested file does not exists
*/
class FileNotFoundException extends \RuntimeException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

namespace Magento\Framework\Storage;


/**
* Exception: RootViolationException
* Exception to be thrown when the a directory root not specified
*/
class RootViolationException extends \RuntimeException
{

Expand Down

0 comments on commit e88833b

Please sign in to comment.