Skip to content

Commit 62e54bd

Browse files
author
Gabriel da Gama
authored
Merge branch '2.4-develop' into backend-allow-login-without-redirect
2 parents df20ae1 + f55f411 commit 62e54bd

File tree

42 files changed

+1709
-353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1709
-353
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Model\Sales\Order\Shipment;
9+
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Sales\Model\ValidatorInterface;
12+
13+
/**
14+
* Validate if requested order items can be shipped according to bundle product shipment type
15+
*/
16+
class BundleShipmentTypeValidator implements ValidatorInterface
17+
{
18+
/**
19+
* @inheritdoc
20+
*/
21+
public function validate($item)
22+
{
23+
$result = [];
24+
if (!$item->isDummy(true)) {
25+
return $result;
26+
}
27+
28+
$message = 'Cannot create shipment as bundle product "%1" has shipment type "%2". ' .
29+
'%3 should be shipped instead.';
30+
31+
if ($item->getHasChildren() && $item->getProductType() === Type::TYPE_BUNDLE) {
32+
$result[] = __(
33+
$message,
34+
$item->getSku(),
35+
__('Separately'),
36+
__('Bundle product options'),
37+
);
38+
}
39+
40+
if ($item->getParentItem() && $item->getParentItem()->getProductType() === Type::TYPE_BUNDLE) {
41+
$result[] = __(
42+
$message,
43+
$item->getParentItem()->getSku(),
44+
__('Together'),
45+
__('Bundle product itself'),
46+
);
47+
}
48+
49+
return $result;
50+
}
51+
}

app/code/Magento/Bundle/etc/di.xml

+7
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,11 @@
234234
</argument>
235235
</arguments>
236236
</type>
237+
<type name="Magento\Sales\Model\Order\Shipment\ShipmentItemsValidator">
238+
<arguments>
239+
<argument name="validators" xsi:type="array">
240+
<item name="shipment_type" xsi:type="object">Magento\Bundle\Model\Sales\Order\Shipment\BundleShipmentTypeValidator</item>
241+
</argument>
242+
</arguments>
243+
</type>
237244
</config>

app/code/Magento/Bundle/i18n/en_US.csv

+3
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ Select...,Select...
105105
Status,Status
106106
Thumbnail,Thumbnail
107107
Type,Type
108+
"Cannot create shipment as bundle product ""%1"" has shipment type ""%2"". %3 should be shipped instead.","Cannot create shipment as bundle product ""%1"" has shipment type ""%2"". %3 should be shipped instead."
109+
"Bundle product itself","Bundle product itself"
110+
"Bundle product options","Bundle product options"

app/code/Magento/Catalog/Test/Mftf/Test/CreateProductAttributeEntityTest/CreateProductAttributeEntityDateTest.xml

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<severity value="BLOCKER"/>
1717
<testCaseId value="MC-10895"/>
1818
<group value="Catalog"/>
19-
<skip>
20-
<issueId value="MC-13817"/>
21-
</skip>
2219
<group value="mtf_migrated"/>
2320
</annotations>
2421

@@ -35,8 +32,9 @@
3532
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
3633
</after>
3734

38-
<!--Generate date for use as default value, needs to be MM/d/YYYY -->
35+
<!--Generate date for use as default value, needs to be MM/d/YYYY and mm/d/yy-->
3936
<generateDate date="now" format="m/j/Y" stepKey="generateDefaultDate"/>
37+
<generateDate date="now" format="m/j/y" stepKey="generateDateCompressedFormat"/>
4038

4139
<!--Navigate to Stores > Attributes > Product.-->
4240
<actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="goToProductAttributes"/>
@@ -57,7 +55,7 @@
5755
<seeOptionIsSelected stepKey="assertInputType" selector="{{AttributePropertiesSection.InputType}}" userInput="{{dateProductAttribute.frontend_input}}"/>
5856
<seeOptionIsSelected stepKey="assertRequired" selector="{{AttributePropertiesSection.ValueRequired}}" userInput="{{dateProductAttribute.is_required_admin}}"/>
5957
<seeInField stepKey="assertAttrCode" selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" userInput="{{dateProductAttribute.attribute_code}}"/>
60-
<seeInField stepKey="assertDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDate}}" userInput="{$generateDefaultDate}"/>
58+
<seeInField stepKey="assertDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDate}}" userInput="{$generateDateCompressedFormat}"/>
6159

6260
<!--Go to New Product page, add Attribute and check values-->
6361
<amOnPage url="{{AdminProductCreatePage.url('4', 'simple')}}" stepKey="goToCreateSimpleProductPage"/>

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ protected function setUp(): void
172172

173173
$this->productFactory = $this->getMockBuilder(
174174
\Magento\Catalog\Model\ResourceModel\ProductFactory::class
175-
)->addMethods(['getTypeId'])
175+
)->disableOriginalConstructor()
176+
->addMethods(['getTypeId'])
176177
->onlyMethods(['create'])
177178
->getMock();
178179

app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php

+21-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Magento\Quote\Model\ShippingAssignmentFactory;
3333
use Magento\Quote\Model\ShippingFactory;
3434
use PHPUnit\Framework\MockObject\MockObject;
35+
use PHPUnit\Framework\MockObject\RuntimeException;
3536
use PHPUnit\Framework\TestCase;
3637

3738
/**
@@ -148,7 +149,7 @@ protected function setUp(): void
148149
'importCustomerAddressData',
149150
'save',
150151
'getShippingRateByCode',
151-
'getShippingMethod'
152+
'getShippingMethod',
152153
]
153154
)
154155
->disableOriginalConstructor()
@@ -167,7 +168,7 @@ protected function setUp(): void
167168
'collectTotals',
168169
'getExtensionAttributes',
169170
'setExtensionAttributes',
170-
'setBillingAddress'
171+
'setBillingAddress',
171172
]
172173
)
173174
->disableOriginalConstructor()
@@ -238,9 +239,7 @@ private function setShippingAssignmentsMocks($shippingMethod): void
238239
->willReturn(null);
239240
$this->shippingAddressMock->expects($this->once())
240241
->method('setLimitCarrier');
241-
$this->cartExtensionMock = $this->getMockBuilder(CartExtension::class)
242-
->addMethods(['getShippingAssignments', 'setShippingAssignments'])
243-
->getMock();
242+
$this->cartExtensionMock = $this->getCartExtensionMock();
244243
$this->cartExtensionFactoryMock->expects($this->once())
245244
->method('create')
246245
->willReturn($this->cartExtensionMock);
@@ -622,4 +621,21 @@ public function testSaveAddressInformation(): void
622621
$this->model->saveAddressInformation($cartId, $addressInformationMock)
623622
);
624623
}
624+
625+
/**
626+
* Build cart extension mock.
627+
*
628+
* @return MockObject
629+
*/
630+
private function getCartExtensionMock(): MockObject
631+
{
632+
$mockBuilder = $this->getMockBuilder(CartExtension::class);
633+
try {
634+
$mockBuilder->addMethods(['getShippingAssignments', 'setShippingAssignments']);
635+
} catch (RuntimeException $e) {
636+
// CartExtension already generated.
637+
}
638+
639+
return $mockBuilder->getMock();
640+
}
625641
}

app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/GuestValidationTest.php

+19-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Quote\Api\Data\PaymentInterface;
2121
use Magento\Store\Model\ScopeInterface;
2222
use PHPUnit\Framework\MockObject\MockObject;
23+
use PHPUnit\Framework\MockObject\RuntimeException;
2324
use PHPUnit\Framework\TestCase;
2425

2526
/**
@@ -78,9 +79,7 @@ protected function setUp(): void
7879
$this->subjectMock = $this->getMockForAbstractClass(GuestPaymentInformationManagementInterface::class);
7980
$this->paymentMock = $this->getMockForAbstractClass(PaymentInterface::class);
8081
$this->addressMock = $this->getMockForAbstractClass(AddressInterface::class);
81-
$this->extensionAttributesMock = $this->getMockBuilder(PaymentExtension::class)
82-
->addMethods(['getAgreementIds'])
83-
->getMock();
82+
$this->extensionAttributesMock = $this->getPaymentExtension();
8483
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
8584
$this->checkoutAgreementsListMock = $this->createMock(
8685
CheckoutAgreementsListInterface::class
@@ -165,4 +164,21 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
165164
"The order wasn't placed. First, agree to the terms and conditions, then try placing your order again."
166165
);
167166
}
167+
168+
/**
169+
* Build payment extension mock.
170+
*
171+
* @return MockObject
172+
*/
173+
private function getPaymentExtension(): MockObject
174+
{
175+
$mockBuilder = $this->getMockBuilder(PaymentExtension::class);
176+
try {
177+
$mockBuilder->addMethods(['getAgreementIds']);
178+
} catch (RuntimeException $e) {
179+
// Payment extension already generated.
180+
}
181+
182+
return $mockBuilder->getMock();
183+
}
168184
}

app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php

+19-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Magento\Quote\Model\Quote;
2323
use Magento\Store\Model\ScopeInterface;
2424
use PHPUnit\Framework\MockObject\MockObject;
25+
use PHPUnit\Framework\MockObject\RuntimeException;
2526
use PHPUnit\Framework\TestCase;
2627

2728
/**
@@ -96,9 +97,7 @@ protected function setUp(): void
9697
->disableOriginalConstructor()
9798
->getMock();
9899
$this->quoteRepositoryMock = $this->getMockForAbstractClass(CartRepositoryInterface::class);
99-
$this->extensionAttributesMock = $this->getMockBuilder(PaymentExtension::class)
100-
->addMethods(['getAgreementIds'])
101-
->getMock();
100+
$this->extensionAttributesMock = $this->getPaymentExtension();
102101
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
103102
$this->checkoutAgreementsListMock = $this->createMock(
104103
CheckoutAgreementsListInterface::class
@@ -232,4 +231,21 @@ public function testBeforeSavePaymentInformation()
232231
->willReturn($this->extensionAttributesMock);
233232
$this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock);
234233
}
234+
235+
/**
236+
* Build payment extension mock.
237+
*
238+
* @return MockObject
239+
*/
240+
private function getPaymentExtension(): MockObject
241+
{
242+
$mockBuilder = $this->getMockBuilder(PaymentExtension::class);
243+
try {
244+
$mockBuilder->addMethods(['getAgreementIds']);
245+
} catch (RuntimeException $e) {
246+
// Payment extension already generated.
247+
}
248+
249+
return $mockBuilder->getMock();
250+
}
235251
}

app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ function (array $attributes) use ($elementMock): string {
6666
}
6767
);
6868
$countryMock = $this->getMockBuilder(AbstractElement::class)
69-
->addMethods(['getValue', 'serialize'])
69+
->onlyMethods(['serialize'])
70+
->addMethods(['getValue'])
7071
->disableOriginalConstructor()
7172
->getMockForAbstractClass();
7273
$countryMock->method('serialize')->willReturnCallback(

app/code/Magento/Downloadable/Test/Unit/Model/Link/UpdateHandlerTest.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Downloadable\Model\Link\UpdateHandler;
1616
use Magento\Downloadable\Model\Product\Type;
1717
use PHPUnit\Framework\MockObject\MockObject;
18+
use PHPUnit\Framework\MockObject\RuntimeException;
1819
use PHPUnit\Framework\TestCase;
1920

2021
/**
@@ -56,7 +57,7 @@ protected function setUp(): void
5657
->getMockForAbstractClass();
5758
$this->linkMock = $this->getMockBuilder(LinkInterface::class)
5859
->getMock();
59-
$this->productExtensionMock = $this->createMock(ProductExtensionInterface::class);
60+
$this->productExtensionMock = $this->getProductExtensionMock();
6061
$this->productExtensionMock->expects($this->once())
6162
->method('getDownloadableProductLinks')
6263
->willReturn([$this->linkMock]);
@@ -145,4 +146,22 @@ public function testExecuteNonDownloadable(): void
145146

146147
$this->assertEquals($this->entityMock, $this->model->execute($this->entityMock));
147148
}
149+
150+
/**
151+
* Build product extension mock.
152+
*
153+
* @return MockObject
154+
*/
155+
private function getProductExtensionMock(): MockObject
156+
{
157+
$mockBuilder = $this->getMockBuilder(ProductExtensionInterface::class)
158+
->disableOriginalConstructor();
159+
try {
160+
$mockBuilder->addMethods(['getDownloadableProductLinks']);
161+
} catch (RuntimeException $e) {
162+
// ProductExtension already generated.
163+
}
164+
165+
return $mockBuilder->getMockForAbstractClass();
166+
}
148167
}

app/code/Magento/Downloadable/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php

+22-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Magento\Quote\Model\Quote\Item;
2222
use Magento\Quote\Model\Quote\ProductOptionFactory;
2323
use PHPUnit\Framework\MockObject\MockObject;
24+
use PHPUnit\Framework\MockObject\RuntimeException;
2425
use PHPUnit\Framework\TestCase;
2526

2627
/**
@@ -170,14 +171,12 @@ public function testProcessProductOptions()
170171
$this->optionFactoryMock->expects($this->once())->method('create')->willReturn($productOptionMock);
171172
$productOptionMock->expects($this->once())->method('getExtensionAttributes')->willReturn(null);
172173

173-
$extAttributeMock = $this->getMockBuilder(ProductOptionExtension::class)
174-
->addMethods(['setDownloadableOption'])
175-
->getMock();
174+
$extAttributeMock = $this->getProductOptionExtensionMock();
176175

177176
$this->objectHelperMock->expects($this->once())->method('populateWithArray')->with(
178177
$downloadableOptionMock,
179178
[
180-
'downloadable_links' => $downloadableLinks
179+
'downloadable_links' => $downloadableLinks,
181180
],
182181
DownloadableOptionInterface::class
183182
);
@@ -206,9 +205,7 @@ public function testProcessProductOptionsWhenItemDoesNotHaveDownloadableLinks()
206205
->method('getOptionByCode')
207206
->with('downloadable_link_ids');
208207

209-
$extAttributeMock = $this->getMockBuilder(ProductOptionExtension::class)
210-
->addMethods(['setDownloadableOption'])
211-
->getMock();
208+
$extAttributeMock = $this->getProductOptionExtensionMock();
212209
$productOptionMock = $this->getMockForAbstractClass(ProductOptionInterface::class);
213210
$productOptionMock->expects($this->any())
214211
->method('getExtensionAttributes')
@@ -228,7 +225,7 @@ public function testProcessProductOptionsWhenItemDoesNotHaveDownloadableLinks()
228225
$this->objectHelperMock->expects($this->once())->method('populateWithArray')->with(
229226
$downloadableOptionMock,
230227
[
231-
'downloadable_links' => $downloadableLinks
228+
'downloadable_links' => $downloadableLinks,
232229
],
233230
DownloadableOptionInterface::class
234231
);
@@ -243,4 +240,21 @@ public function testProcessProductOptionsWhenItemDoesNotHaveDownloadableLinks()
243240

244241
$this->assertEquals($cartItemMock, $this->model->processOptions($cartItemMock));
245242
}
243+
244+
/**
245+
* Build product option extension mock.
246+
*
247+
* @return MockObject
248+
*/
249+
private function getProductOptionExtensionMock(): MockObject
250+
{
251+
$mockBuilder = $this->getMockBuilder(ProductOptionExtension::class);
252+
try {
253+
$mockBuilder->addMethods(['setDownloadableOption']);
254+
} catch (RuntimeException $e) {
255+
// ProductOptionExtension already generated.
256+
}
257+
258+
return $mockBuilder->getMock();
259+
}
246260
}

0 commit comments

Comments
 (0)