Skip to content

Commit

Permalink
Cleanup not used dependencies from Media class
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Jan 4, 2024
1 parent e1e7fc2 commit 45e61cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
4 changes: 0 additions & 4 deletions src/Service/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ class Media
protected Connection $connection;

public function __construct(
protected ModuleSettings $moduleSettings,
protected Config $shopConfig,
ConnectionProviderInterface $connectionProvider,
protected UtilsObject $utilsObject,
public ThumbnailGeneratorInterface $thumbnailGenerator,
public ImageResourceInterface $imageResource,
protected NamingServiceInterface $namingService,
protected MediaRepositoryInterface $mediaRepository,
private FileSystemServiceInterface $fileSystemService,
protected FolderServiceInterface $folderService,
protected ShopAdapterInterface $shopAdapter,
) {
$this->connection = $connectionProvider->get();
Expand Down
2 changes: 0 additions & 2 deletions src/Service/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ services:
_defaults:
public: false
autowire: true
bind:
OxidEsales\Eshop\Core\UtilsObject: '@=service("OxidEsales\\MediaLibrary\\Core\\Registry").getUtilsObject()'

OxidEsales\MediaLibrary\Service\FileSystemServiceInterface:
class: OxidEsales\MediaLibrary\Service\FileSystemService
Expand Down
10 changes: 3 additions & 7 deletions tests/Integration/Service/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,12 @@ protected function getSut(
$shopAdapterStub->method('generateUniqueId')->willReturn(uniqid());

return new MediaMock(
$moduleSettings ?: $this->containerFactory->get(ModuleSettings::class),
$shopConfig ?: Registry::getConfig(),
$connectionProvider ?: new ConnectionProvider(),
$utilsObject ?: Registry::getUtilsObject(),
$thumbnailGenerator ?: $this->containerFactory->get(ThumbnailGeneratorInterface::class),
$imageResourceMock,
shopConfig: $shopConfig ?: Registry::getConfig(),
connectionProvider: $connectionProvider ?: new ConnectionProvider(),
imageResource: $imageResourceMock,
namingService: $namingService ?: $this->containerFactory->get(NamingServiceInterface::class),
mediaRepository: $this->containerFactory->get(MediaRepositoryInterface::class),
fileSystemService: $this->containerFactory->get(FileSystemServiceInterface::class),
folderService: $this->containerFactory->get(FolderServiceInterface::class),
shopAdapter: $shopAdapterStub
);
}
Expand Down
24 changes: 5 additions & 19 deletions tests/Unit/Service/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,8 @@ public function testUploadMedia()

public function getRenameDataProvider(): array
{
$oMedia = new Media(
$this->createStub(ModuleSettings::class),
$this->createStub(Config::class),
$this->createStub(ConnectionProviderInterface::class),
$this->createStub(UtilsObject::class),
$this->createStub(ThumbnailGeneratorInterface::class),
$this->createStub(ImageResourceInterface::class),
$oMedia = $this->getSut(
namingService: ContainerFactory::getInstance()->getContainer()->get(NamingServiceInterface::class),
mediaRepository: $this->createStub(MediaRepositoryInterface::class),
fileSystemService: $this->createStub(FileSystemServiceInterface::class),
folderService: $this->createStub(FolderServiceInterface::class),
shopAdapter: $this->createStub(ShopAdapterInterface::class)
);

$defaultThumbnailSize = $oMedia->imageResource->getDefaultThumbnailSize();
Expand Down Expand Up @@ -567,17 +557,13 @@ protected function getSut(
$connectionProvider
);
return new MediaMock(
$moduleSettings ?: $this->createStub(ModuleSettings::class),
$shopConfig ?: $this->createStub(Config::class),
$connectionProvider ?: $this->createStub(ConnectionProviderInterface::class),
$utilsObject ?: $this->createStub(UtilsObject::class),
$thumbnailGenerator ?: $this->createStub(ThumbnailGeneratorInterface::class),
$imageResourceMock,
shopConfig: $shopConfig ?: $this->createStub(Config::class),
connectionProvider: $connectionProvider ?: $this->createStub(ConnectionProviderInterface::class),
imageResource: $imageResourceMock,
namingService: $namingService ?? $this->createStub(NamingServiceInterface::class),
mediaRepository: $mediaRepository ?? $this->createStub(MediaRepositoryInterface::class),
fileSystemService: $fileSystemService ?? $this->createPartialMock(FileSystemService::class, []),
folderService: $this->createStub(FolderServiceInterface::class),
shopAdapter: $this->createStub(ShopAdapterInterface::class)
shopAdapter: $this->createStub(ShopAdapterInterface::class),
);
}

Expand Down

0 comments on commit 45e61cd

Please sign in to comment.