Skip to content

Commit e22b7a2

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #16103: [Forwardport] fixed word typo (by @hitesh-wagento) - #16117: Captcha: Added unit test for CheckRegisterCheckoutObserver (by @rogyar) - #16121: [Forwardport] Improve retrieval of first array element (by @thomas-blackbird) - #16128: [Forwardport] Disabling sorting in glob and scandir functions for better performance (by @lfluvisotto) - #16036: [Forwardport] Fix issue #15832 (by @chirag-wagento) - #15975: [Forwardport] #15308 removed extraneous margin (by @chirag-wagento) - #15982: Fix Magento\Sales\Service\V1\ShipmentGetTest::testShipmentGet (by @slackerzz) - #15974: Fix magento/inventory#1339 issue - Fix \Magento\Sales\Service\V1\ShipmentCreateTest::testInvoke (by @slackerzz) - #16006: 1334: CreateOrderBackendTest rework to support MSI 'Reorder' button new behaviour. (by @nmalevanec) - #15685: Fulltext replacement with like condition (by @phoenix128) Fixed GitHub Issues: - #15832: No button-primary__font-weight (reported by @DanielRuf) has been fixed in #16036 by @chirag-wagento in 2.3-develop branch Related commits: 1. d7e77e6 2. c4de267 - #15308: extraneous margins on product list and product list items (reported by @DanielRuf) has been fixed in #15975 by @chirag-wagento in 2.3-develop branch Related commits: 1. eee2e7c - #1350: Install Quits on install on Magento_Catalog (reported by @Zaylril) has been fixed in #15982 by @slackerzz in 2.3-develop branch Related commits: 1. 9e5757d 2. 1555b96 3. 039e71c - #680: More settings for image storage (reported by @bubach) has been fixed in #16006 by @nmalevanec in 2.3-develop branch Related commits: 1. 0501e17 2. 731b58f 3. 7c3d53f 4. 0d06ad8 - #1221: "Uncaught TypeError: Event.observe is not a function" In Version 0.74.0-beta6 (reported by @RisingRavi) has been fixed in #15685 by @phoenix128 in 2.3-develop branch Related commits: 1. 7259c4b
2 parents 2910d8b + b9934f3 commit e22b7a2

File tree

23 files changed

+304
-41
lines changed

23 files changed

+304
-41
lines changed
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
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\Captcha\Test\Unit\Observer;
9+
10+
use Magento\Captcha\Model\DefaultModel as CaptchaModel;
11+
use Magento\Captcha\Observer\CheckRegisterCheckoutObserver;
12+
use Magento\Captcha\Helper\Data as CaptchaDataHelper;
13+
use Magento\Framework\App\Action\Action;
14+
use Magento\Framework\App\ActionFlag;
15+
use Magento\Captcha\Observer\CaptchaStringResolver;
16+
use Magento\Checkout\Model\Type\Onepage;
17+
use Magento\Framework\App\Request\Http;
18+
use Magento\Framework\App\Response\Http as HttpResponse;
19+
use Magento\Framework\Event\Observer;
20+
use Magento\Framework\Json\Helper\Data as JsonHelper;
21+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
22+
use Magento\Quote\Model\Quote;
23+
24+
/**
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
*/
27+
class CheckRegisterCheckoutObserverTest extends \PHPUnit\Framework\TestCase
28+
{
29+
const FORM_ID = 'register_during_checkout';
30+
31+
/**
32+
* @var CheckRegisterCheckoutObserver
33+
*/
34+
private $checkRegisterCheckoutObserver;
35+
36+
/**
37+
* @var ObjectManager
38+
*/
39+
private $objectManager;
40+
41+
/**
42+
* @var Observer
43+
*/
44+
private $observer;
45+
46+
/**
47+
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
48+
*/
49+
private $responseMock;
50+
51+
/**
52+
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
53+
*/
54+
private $requestMock;
55+
56+
/**
57+
* @var ActionFlag|\PHPUnit_Framework_MockObject_MockObject
58+
*/
59+
private $actionFlagMock;
60+
61+
/**
62+
* @var CaptchaStringResolver|\PHPUnit_Framework_MockObject_MockObject
63+
*/
64+
private $captchaStringResolverMock;
65+
66+
/**
67+
* @var JsonHelper|\PHPUnit_Framework_MockObject_MockObject
68+
*/
69+
private $jsonHelperMock;
70+
71+
/**
72+
* @var CaptchaModel|\PHPUnit_Framework_MockObject_MockObject
73+
*/
74+
private $captchaModelMock;
75+
76+
/**
77+
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
78+
*/
79+
private $quoteModelMock;
80+
81+
/**
82+
* @var Action|\PHPUnit_Framework_MockObject_MockObject
83+
*/
84+
private $controllerMock;
85+
86+
protected function setUp()
87+
{
88+
$onepageModelTypeMock = $this->createMock(Onepage::class);
89+
$captchaHelperMock = $this->createMock(CaptchaDataHelper::class);
90+
$this->objectManager = new ObjectManager($this);
91+
$this->actionFlagMock = $this->createMock(ActionFlag::class);
92+
$this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
93+
$this->captchaModelMock = $this->createMock(CaptchaModel::class);
94+
$this->quoteModelMock = $this->createMock(Quote::class);
95+
$this->controllerMock = $this->createMock(Action::class);
96+
$this->requestMock = $this->createMock(Http::class);
97+
$this->responseMock = $this->createMock(HttpResponse::class);
98+
$this->observer = new Observer(['controller_action' => $this->controllerMock]);
99+
$this->jsonHelperMock = $this->createMock(JsonHelper::class);
100+
101+
$this->checkRegisterCheckoutObserver = $this->objectManager->getObject(
102+
CheckRegisterCheckoutObserver::class,
103+
[
104+
'helper' => $captchaHelperMock,
105+
'actionFlag' => $this->actionFlagMock,
106+
'captchaStringResolver' => $this->captchaStringResolverMock,
107+
'typeOnepage' => $onepageModelTypeMock,
108+
'jsonHelper' => $this->jsonHelperMock
109+
]
110+
);
111+
112+
$captchaHelperMock->expects($this->once())
113+
->method('getCaptcha')
114+
->with(self::FORM_ID)
115+
->willReturn($this->captchaModelMock);
116+
$onepageModelTypeMock->expects($this->once())
117+
->method('getQuote')
118+
->willReturn($this->quoteModelMock);
119+
}
120+
121+
public function testCheckRegisterCheckoutForGuest()
122+
{
123+
$this->quoteModelMock->expects($this->once())
124+
->method('getCheckoutMethod')
125+
->willReturn(Onepage::METHOD_GUEST);
126+
$this->captchaModelMock->expects($this->never())
127+
->method('isRequired');
128+
129+
$this->checkRegisterCheckoutObserver->execute($this->observer);
130+
}
131+
132+
public function testCheckRegisterCheckoutWithNoCaptchaRequired()
133+
{
134+
$this->quoteModelMock->expects($this->once())
135+
->method('getCheckoutMethod')
136+
->willReturn(Onepage::METHOD_REGISTER);
137+
$this->captchaModelMock->expects($this->once())
138+
->method('isRequired')
139+
->willReturn(false);
140+
$this->captchaModelMock->expects($this->never())
141+
->method('isCorrect');
142+
143+
$this->checkRegisterCheckoutObserver->execute($this->observer);
144+
}
145+
146+
public function testCheckRegisterCheckoutWithIncorrectCaptcha()
147+
{
148+
$captchaValue = 'some_word';
149+
$encodedJsonValue = '{}';
150+
151+
$this->quoteModelMock->expects($this->once())
152+
->method('getCheckoutMethod')
153+
->willReturn(Onepage::METHOD_REGISTER);
154+
$this->captchaModelMock->expects($this->once())
155+
->method('isRequired')
156+
->willReturn(true);
157+
$this->controllerMock->expects($this->once())
158+
->method('getRequest')
159+
->willReturn($this->requestMock);
160+
$this->controllerMock->expects($this->once())
161+
->method('getResponse')
162+
->willReturn($this->responseMock);
163+
$this->controllerMock->expects($this->once())
164+
->method('getResponse')
165+
->willReturn($this->responseMock);
166+
$this->captchaStringResolverMock->expects($this->once())
167+
->method('resolve')
168+
->with($this->requestMock, self::FORM_ID)
169+
->willReturn($captchaValue);
170+
$this->captchaModelMock->expects($this->once())
171+
->method('isCorrect')
172+
->with($captchaValue)
173+
->willReturn(false);
174+
$this->actionFlagMock->expects($this->once())
175+
->method('set')
176+
->with('', Action::FLAG_NO_DISPATCH, true);
177+
$this->jsonHelperMock->expects($this->once())
178+
->method('jsonEncode')
179+
->willReturn($encodedJsonValue);
180+
$this->responseMock->expects($this->once())
181+
->method('representJson')
182+
->with($encodedJsonValue);
183+
184+
$this->checkRegisterCheckoutObserver->execute($this->observer);
185+
}
186+
187+
public function testCheckRegisterCheckoutWithCorrectCaptcha()
188+
{
189+
$this->quoteModelMock->expects($this->once())
190+
->method('getCheckoutMethod')
191+
->willReturn(Onepage::METHOD_REGISTER);
192+
$this->captchaModelMock->expects($this->once())
193+
->method('isRequired')
194+
->willReturn(true);
195+
$this->controllerMock->expects($this->once())
196+
->method('getRequest')
197+
->willReturn($this->requestMock);
198+
$this->captchaStringResolverMock->expects($this->once())
199+
->method('resolve')
200+
->with($this->requestMock, self::FORM_ID)
201+
->willReturn('some_word');
202+
$this->captchaModelMock->expects($this->once())
203+
->method('isCorrect')
204+
->with('some_word')
205+
->willReturn(true);
206+
$this->actionFlagMock->expects($this->never())
207+
->method('set');
208+
209+
$this->checkRegisterCheckoutObserver->execute($this->observer);
210+
}
211+
}

app/code/Magento/Rule/Model/Action/AbstractAction.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ public function __construct(
4949

5050
$this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions();
5151

52-
foreach (array_keys($this->getAttributeOption()) as $attr) {
53-
$this->setAttribute($attr);
54-
break;
52+
$attributes = $this->getAttributeOption();
53+
if ($attributes) {
54+
reset($attributes);
55+
$this->setAttribute(key($attributes));
5556
}
56-
foreach (array_keys($this->getOperatorOption()) as $operator) {
57-
$this->setOperator($operator);
58-
break;
57+
58+
$operators = $this->getOperatorOption();
59+
if ($operators) {
60+
reset($operators);
61+
$this->setOperator(key($operators));
5962
}
6063
}
6164

app/code/Magento/Rule/Model/Condition/Combine.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public function __construct(Context $context, array $data = [])
4646
$this->loadAggregatorOptions();
4747
$options = $this->getAggregatorOptions();
4848
if ($options) {
49-
foreach (array_keys($options) as $aggregator) {
50-
$this->setAggregator($aggregator);
51-
break;
52-
}
49+
reset($options);
50+
$this->setAggregator(key($options));
5351
}
5452
}
5553

@@ -90,9 +88,10 @@ public function getAggregatorName()
9088
public function getAggregatorElement()
9189
{
9290
if ($this->getAggregator() === null) {
93-
foreach (array_keys($this->getAggregatorOption()) as $key) {
94-
$this->setAggregator($key);
95-
break;
91+
$options = $this->getAggregatorOption();
92+
if ($options) {
93+
reset($options);
94+
$this->setAggregator(key($options));
9695
}
9796
}
9897
return $this->getForm()->addField(

app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/module/_listings.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@
167167
.column.main {
168168
.product {
169169
&-items {
170-
margin-left: -@indent__base;
170+
margin-left: 0;
171171
}
172172

173173
&-item {
174-
padding-left: @indent__base;
174+
padding-left: 0;
175175
}
176176
}
177177
}

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentCreateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public function testInvoke()
4343
'qty' => $orderItem->getQtyOrdered(),
4444
'additional_data' => null,
4545
'description' => null,
46-
'entity_id' => null,
46+
'entity_id' => 1,
4747
'name' => null,
4848
'parent_id' => null,
4949
'price' => null,
5050
'product_id' => null,
5151
'row_total' => null,
52-
'sku' => null,
52+
'sku' => 'simple',
5353
'weight' => null,
5454
],
5555
];

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentGetTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Sales\Service\V1;
77

8+
use Magento\Framework\Api\ExtensibleDataInterface;
9+
use Magento\Framework\Api\SimpleDataObjectConverter;
810
use Magento\TestFramework\TestCase\WebapiAbstract;
911

1012
/**
@@ -57,7 +59,18 @@ public function testShipmentGet()
5759
unset($data['tracks']);
5860
foreach ($data as $key => $value) {
5961
if (!empty($value)) {
60-
$this->assertEquals($shipment->getData($key), $value, $key);
62+
if ($key === ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY) {
63+
foreach ($value as $extensionAttributeKey => $extensionAttributeValue) {
64+
$methodName = 'get' .
65+
SimpleDataObjectConverter::snakeCaseToUpperCamelCase($extensionAttributeKey);
66+
$this->assertEquals(
67+
$shipment->getExtensionAttributes()->$methodName(),
68+
$extensionAttributeValue
69+
);
70+
}
71+
} else {
72+
$this->assertEquals($shipment->getData($key), $value, $key);
73+
}
6174
}
6275
}
6376
$shipmentItem = $this->objectManager->get(\Magento\Sales\Model\Order\Shipment\Item::class);

dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOrderBackendTest.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<data name="creditCard/data/payment_code" xsi:type="string">braintree</data>
2828
<data name="configData" xsi:type="string">braintree</data>
2929
<data name="status" xsi:type="string">Processing</data>
30-
<data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Email, Hold, Invoice, Ship, Reorder, Edit</data>
31-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" />
30+
<data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Email, Invoice, Reorder, Edit</data>
31+
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
3232
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
3333
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
3434
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
@@ -55,9 +55,9 @@
5555
<data name="creditCard/dataset" xsi:type="string">visa_default</data>
5656
<data name="creditCard/data/payment_code" xsi:type="string">braintree</data>
5757
<data name="configData" xsi:type="string">braintree, braintree_sale</data>
58-
<data name="status" xsi:type="string">Processing</data>
59-
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Hold, Ship, Reorder</data>
60-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" />
58+
<data name="status" xsi:type="string">Complete</data>
59+
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Reorder</data>
60+
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
6161
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
6262
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
6363
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
@@ -83,7 +83,7 @@
8383
<data name="creditCard/dataset" xsi:type="string">visa_braintree_fraud_rejected</data>
8484
<data name="configData" xsi:type="string">braintree</data>
8585
<data name="status" xsi:type="string">Processing</data>
86-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" />
86+
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
8787
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
8888
<constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" />
8989
</variation>

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ class Actions extends Block
137137
*/
138138
protected $confirmModal = '.confirm._show[data-role=modal]';
139139

140+
/**
141+
* Is shipment can be created.
142+
*
143+
* @return bool
144+
*/
145+
public function canShip()
146+
{
147+
return $this->_rootElement->find($this->ship)->isVisible();
148+
}
149+
140150
/**
141151
* Ship order.
142152
*

dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</data>
2020
<data name="payment/method" xsi:type="string">cashondelivery</data>
2121
<data name="configData" xsi:type="string">cashondelivery</data>
22-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" />
22+
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
2323
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
2424
<constraint name="Magento\Catalog\Test\Constraint\AssertProductsOutOfStock" />
2525
</variation>
@@ -35,7 +35,7 @@
3535
</data>
3636
<data name="payment/method" xsi:type="string">cashondelivery</data>
3737
<data name="configData" xsi:type="string">cashondelivery</data>
38-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" />
38+
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
3939
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
4040
<constraint name="Magento\Sales\Test\Constraint\AssertReorderButtonIsNotVisibleOnFrontend" />
4141
</variation>

0 commit comments

Comments
 (0)