-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into ASI-1833-add-ability-to-disable-rendi…
…tions-functionality-to-stores-configuration
- Loading branch information
Showing
32 changed files
with
1,066 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
app/code/Magento/Checkout/Test/Unit/Model/TotalsInformationManagementTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Checkout\Test\Unit\Model; | ||
|
||
use Magento\Checkout\Api\Data\TotalsInformationInterface; | ||
use Magento\Checkout\Model\TotalsInformationManagement; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
use Magento\Quote\Api\CartTotalRepositoryInterface; | ||
use Magento\Quote\Model\Quote\Address; | ||
|
||
class TotalsInformationManagementTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* @var CartRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
private $cartRepositoryMock; | ||
|
||
/** | ||
* @var CartTotalRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
private $cartTotalRepositoryMock; | ||
|
||
/** | ||
* @var TotalsInformationManagement | ||
*/ | ||
private $totalsInformationManagement; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->objectManager = new ObjectManager($this); | ||
$this->cartRepositoryMock = $this->createMock( | ||
CartRepositoryInterface::class | ||
); | ||
$this->cartTotalRepositoryMock = $this->createMock( | ||
CartTotalRepositoryInterface::class | ||
); | ||
|
||
$this->totalsInformationManagement = $this->objectManager->getObject( | ||
TotalsInformationManagement::class, | ||
[ | ||
'cartRepository' => $this->cartRepositoryMock, | ||
'cartTotalRepository' => $this->cartTotalRepositoryMock, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Test for \Magento\Checkout\Model\TotalsInformationManagement::calculate. | ||
* | ||
* @param string|null $carrierCode | ||
* @param string|null $carrierMethod | ||
* @param int $methodSetCount | ||
* @dataProvider dataProviderCalculate | ||
*/ | ||
public function testCalculate(?string $carrierCode, ?string $carrierMethod, int $methodSetCount) | ||
{ | ||
$cartId = 1; | ||
$cartMock = $this->createMock( | ||
\Magento\Quote\Model\Quote::class | ||
); | ||
$cartMock->expects($this->once())->method('getItemsCount')->willReturn(1); | ||
$cartMock->expects($this->once())->method('getIsVirtual')->willReturn(false); | ||
$this->cartRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($cartMock); | ||
$this->cartTotalRepositoryMock->expects($this->once())->method('get')->with($cartId); | ||
|
||
$addressInformationMock = $this->createMock( | ||
TotalsInformationInterface::class | ||
); | ||
$addressMock = $this->getMockBuilder(Address::class) | ||
->addMethods( | ||
[ | ||
'setShippingMethod', | ||
'setCollectShippingRates', | ||
] | ||
) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$addressInformationMock->expects($this->once())->method('getAddress')->willReturn($addressMock); | ||
$addressInformationMock->expects($this->any())->method('getShippingCarrierCode')->willReturn($carrierCode); | ||
$addressInformationMock->expects($this->any())->method('getShippingMethodCode')->willReturn($carrierMethod); | ||
$cartMock->expects($this->once())->method('setShippingAddress')->with($addressMock); | ||
$cartMock->expects($this->exactly($methodSetCount))->method('getShippingAddress')->willReturn($addressMock); | ||
$addressMock->expects($this->exactly($methodSetCount)) | ||
->method('setCollectShippingRates')->with(true)->willReturn($addressMock); | ||
$addressMock->expects($this->exactly($methodSetCount)) | ||
->method('setShippingMethod')->with($carrierCode . '_' . $carrierMethod); | ||
$cartMock->expects($this->once())->method('collectTotals'); | ||
|
||
$this->totalsInformationManagement->calculate($cartId, $addressInformationMock); | ||
} | ||
|
||
/** | ||
* Data provider for testCalculate. | ||
* | ||
* @return array | ||
*/ | ||
public function dataProviderCalculate(): array | ||
{ | ||
return [ | ||
[ | ||
null, | ||
null, | ||
0 | ||
], | ||
[ | ||
null, | ||
'carrier_method', | ||
0 | ||
], | ||
[ | ||
'carrier_code', | ||
null, | ||
0 | ||
], | ||
[ | ||
'carrier_code', | ||
'carrier_method', | ||
1 | ||
] | ||
]; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...o/MediaGalleryRenditions/Test/Mftf/Test/AdminMediaGalleryInsertLargeImageFileSizeTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="AdminMediaGalleryInsertLargeImageFileSizeTest"> | ||
<annotations> | ||
<features value="AdminMediaGalleryInsertLargeImageFileSizeTest"/> | ||
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1806"/> | ||
<title value="Admin user should see correct image file size after rendition"/> | ||
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1507933/scenarios/5200023"/> | ||
<stories value="User inserts image rendition to the content"/> | ||
<description value="Admin user should see correct image file size after rendition"/> | ||
<severity value="AVERAGE"/> | ||
<group value="media_gallery_ui"/> | ||
</annotations> | ||
<before> | ||
<createData entity="SimpleSubCategory" stepKey="category"/> | ||
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> | ||
</before> | ||
<after> | ||
<!-- Delete uploaded image --> | ||
<actionGroup ref="AdminOpenCategoryGridPageActionGroup" stepKey="openCategoryPageFoDelete"/> | ||
<actionGroup ref="AdminEditCategoryInGridPageActionGroup" stepKey="editCategoryItemForDelete"> | ||
<argument name="categoryName" value="$category.name$"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryForDelete"/> | ||
<actionGroup ref="AdminEnhancedMediaGalleryEnableMassActionModeActionGroup" stepKey="enableMassActionToDeleteImages"/> | ||
<actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectSecondImageToDelete"> | ||
<argument name="imageName" value="{{ImageUpload.fileName}}"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clickDeleteSelectedButton"/> | ||
<actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/> | ||
|
||
<!-- Delete category --> | ||
<deleteData createDataKey="category" stepKey="deleteCategory"/> | ||
</after> | ||
|
||
<!-- Open category page --> | ||
<actionGroup ref="AdminOpenCategoryGridPageActionGroup" stepKey="openCategoryPage"/> | ||
<actionGroup ref="AdminEditCategoryInGridPageActionGroup" stepKey="editCategoryItem"> | ||
<argument name="categoryName" value="$category.name$"/> | ||
</actionGroup> | ||
|
||
<!-- Add image to category from gallery --> | ||
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGallery"/> | ||
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="addCategoryImage"> | ||
<argument name="image" value="ImageUpload"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminMediaGalleryClickImageInGridActionGroup" stepKey="selectImage"> | ||
<argument name="imageName" value="{{ImageUpload.fileName}}"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="addSelected"/> | ||
|
||
|
||
<!-- Assert added image size --> | ||
<actionGroup ref="AdminAssertImageUploadFileSizeThanActionGroup" stepKey="assertSize"> | ||
<argument name="fileSize" value="26 KB"/> | ||
</actionGroup> | ||
</test> | ||
</tests> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/code/Magento/MediaGalleryUi/Controller/Adminhtml/Image/OnInsert.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\MediaGalleryUi\Controller\Adminhtml\Image; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\App\Action\HttpPostActionInterface; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use Magento\MediaGalleryUi\Model\InsertImageData\GetInsertImageData; | ||
|
||
/** | ||
* OnInsert action returns on insert image details | ||
*/ | ||
class OnInsert extends Action implements HttpPostActionInterface | ||
{ | ||
/** | ||
* @see _isAllowed() | ||
*/ | ||
public const ADMIN_RESOURCE = 'Magento_MediaGalleryUiApi::insert_assets'; | ||
|
||
/** | ||
* @var JsonFactory | ||
*/ | ||
private $resultJsonFactory; | ||
|
||
/** | ||
* @var GetInsertImageData | ||
*/ | ||
private $getInsertImageData; | ||
|
||
/** | ||
* @param Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param GetInsertImageData $getInsertImageData | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
JsonFactory $resultJsonFactory, | ||
GetInsertImageData $getInsertImageData | ||
) { | ||
parent::__construct($context); | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->getInsertImageData = $getInsertImageData; | ||
} | ||
|
||
/** | ||
* Return a content (just a link or an html block) for inserting image to the content | ||
* | ||
* @return ResultInterface | ||
*/ | ||
public function execute() | ||
{ | ||
$data = $this->getRequest()->getParams(); | ||
$insertImageData = $this->getInsertImageData->execute( | ||
$data['filename'], | ||
(bool)$data['force_static_path'], | ||
(bool)$data['as_is'], | ||
isset($data['store']) ? (int)$data['store'] : null | ||
); | ||
|
||
return $this->resultJsonFactory->create()->setData([ | ||
'content' => $insertImageData->getContent(), | ||
'size' => $insertImageData->getSize(), | ||
'type' => $insertImageData->getType(), | ||
]); | ||
} | ||
} |
Oops, something went wrong.