Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 6200e46

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento/magento2#16909: Stabilize Travis CI integration tests suite (by @ishakhsuvarov) - magento/magento2#16879: [Port 2.3] Captcha: Added unit test for CheckGuestCheckoutObserver (by @rogyar) - magento/magento2#16820: Add missing false-check to the ConfiguredRegularPrice price-model (by @ronak2ram) - magento/graphql-ce#101: Additional checks for fragments added in category tree (by @rogyar) - magento/graphql-ce#102: Fix the category tree depth calculation bug (by @dmytro-ch) - magento/graphql-ce#119: GraphQL-116: Wrong category table name resolving (by @naydav) - magento/magento2#16603: [Forwardport] Fix error in payment void method (by @gelanivishal) - #109: #64: fix issue with Export Type UI (by @dmanners) - magento/magento2#16596: [Forwardport] Incorrect value NULL was passed to DataObject constructor. It caused � (by @gelanivishal) - magento/magento2#16518: [Forwardport] Use constant time string comparison in FormKey validator (by @gelanivishal) Fixed GitHub Issues: - magento/magento2#100: Oracle and Other RDBMS Status? (reported by @dicgf8) has been fixed in magento/graphql-ce#102 by @dmytro-ch in 2.3-develop branch Related commits: 1. 9116d82 - magento/magento2#116: EE vs CE (reported by @gondo) has been fixed in magento/graphql-ce#119 by @naydav in 2.3-develop branch Related commits: 1. 4a4bbe2 - magento/magento2#16184: Argument 1 passed to Magento\Sales\Model\Order\Payment must be an instance of Magento\Framework\DataObject, none given (reported by @Jakhotiya) has been fixed in magento/magento2#16603 by @gelanivishal in 2.3-develop branch Related commits: 1. a1f5fa5
2 parents f54386d + a77426d commit 6200e46

File tree

12 files changed

+342
-16
lines changed

12 files changed

+342
-16
lines changed

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,14 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = ''
814814
{
815815
try {
816816
$response = $this->getResponse();
817-
if ($voidPayment && $response->getXTransId() && strtoupper($response->getXType())
818-
== self::REQUEST_TYPE_AUTH_ONLY
817+
if ($voidPayment
818+
&& $response->getXTransId()
819+
&& strtoupper($response->getXType()) == self::REQUEST_TYPE_AUTH_ONLY
819820
) {
820-
$order->getPayment()->setTransactionId(null)->setParentTransactionId($response->getXTransId())->void();
821+
$order->getPayment()
822+
->setTransactionId(null)
823+
->setParentTransactionId($response->getXTransId())
824+
->void($response);
821825
}
822826
$order->registerCancellation($message)->save();
823827
} catch (\Exception $e) {
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\CheckGuestCheckoutObserver;
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 CheckGuestCheckoutObserverTest extends \PHPUnit\Framework\TestCase
28+
{
29+
const FORM_ID = 'guest_checkout';
30+
31+
/**
32+
* @var CheckGuestCheckoutObserver
33+
*/
34+
private $checkGuestCheckoutObserver;
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->checkGuestCheckoutObserver = $this->objectManager->getObject(
102+
CheckGuestCheckoutObserver::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 testCheckGuestCheckoutForRegister()
122+
{
123+
$this->quoteModelMock->expects($this->once())
124+
->method('getCheckoutMethod')
125+
->willReturn(Onepage::METHOD_REGISTER);
126+
$this->captchaModelMock->expects($this->never())
127+
->method('isRequired');
128+
129+
$this->checkGuestCheckoutObserver->execute($this->observer);
130+
}
131+
132+
public function testCheckGuestCheckoutWithNoCaptchaRequired()
133+
{
134+
$this->quoteModelMock->expects($this->once())
135+
->method('getCheckoutMethod')
136+
->willReturn(Onepage::METHOD_GUEST);
137+
$this->captchaModelMock->expects($this->once())
138+
->method('isRequired')
139+
->willReturn(false);
140+
$this->captchaModelMock->expects($this->never())
141+
->method('isCorrect');
142+
143+
$this->checkGuestCheckoutObserver->execute($this->observer);
144+
}
145+
146+
public function testCheckGuestCheckoutWithIncorrectCaptcha()
147+
{
148+
$captchaValue = 'some_word';
149+
$encodedJsonValue = '{}';
150+
151+
$this->quoteModelMock->expects($this->once())
152+
->method('getCheckoutMethod')
153+
->willReturn(Onepage::METHOD_GUEST);
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->checkGuestCheckoutObserver->execute($this->observer);
185+
}
186+
187+
public function testCheckGuestCheckoutWithCorrectCaptcha()
188+
{
189+
$this->quoteModelMock->expects($this->once())
190+
->method('getCheckoutMethod')
191+
->willReturn(Onepage::METHOD_GUEST);
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->checkGuestCheckoutObserver->execute($this->observer);
210+
}
211+
}

app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public function join(FieldNode $fieldNode, AbstractCollection $collection) : voi
2828

2929
/** @var FieldNode $field */
3030
foreach ($query as $field) {
31+
if ($field->kind === 'InlineFragment') {
32+
continue;
33+
}
34+
3135
if (!$collection->isAttributeAdded($field->name->value)) {
3236
$collection->addAttributeToSelect($field->name->value);
3337
}

app/code/Magento/CatalogGraphQl/Model/Category/DepthCalculator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public function calculate(FieldNode $fieldNode) : int
2626
$depth = count($selections) ? 1 : 0;
2727
$childrenDepth = [0];
2828
foreach ($selections as $node) {
29+
if ($node->kind === 'InlineFragment') {
30+
continue;
31+
}
32+
2933
$childrenDepth[] = $this->calculate($node);
3034
}
3135

app/code/Magento/CatalogGraphQl/Model/Category/LevelCalculator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function calculate(int $rootCategoryId) : int
3737
{
3838
$connection = $this->resourceConnection->getConnection();
3939
$select = $connection->select()
40-
->from($connection->getTableName('catalog_category_entity'), 'level')
40+
->from($this->resourceConnection->getTableName('catalog_category_entity'), 'level')
4141
->where($this->resourceCategory->getLinkField() . " = ?", $rootCategoryId);
4242
return (int) $connection->fetchOne($select);
4343
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/CategoryTree.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
class CategoryTree
2525
{
2626
/**
27-
* In depth we need to calculate only children nodes, so 2 first wrapped nodes should be ignored
27+
* In depth we need to calculate only children nodes, so the first wrapped node should be ignored
2828
*/
29-
const DEPTH_OFFSET = 2;
29+
const DEPTH_OFFSET = 1;
3030

3131
/**
3232
* @var CollectionFactory
@@ -143,6 +143,10 @@ private function joinAttributesRecursively(Collection $collection, FieldNode $fi
143143

144144
/** @var FieldNode $node */
145145
foreach ($subSelection as $node) {
146+
if ($node->kind === 'InlineFragment') {
147+
continue;
148+
}
149+
146150
$this->joinAttributesRecursively($collection, $node);
147151
}
148152
}

app/code/Magento/ImportExport/view/adminhtml/templates/export/form/before.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ require([
6464
this.modifyFilterGrid();
6565
}
6666
} else {
67+
this.previousGridEntity = '';
6768
$('export_filter_container').hide();
6869
}
6970
}

app/code/Magento/Wishlist/Model/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ public function getProductUrl()
473473
public function getBuyRequest()
474474
{
475475
$option = $this->getOptionByCode('info_buyRequest');
476-
$initialData = $option ? $this->serializer->unserialize($option->getValue()) : null;
476+
$initialData = $option ? $this->serializer->unserialize($option->getValue()) : [];
477477

478478
if ($initialData instanceof \Magento\Framework\DataObject) {
479479
$initialData = $initialData->getData();

0 commit comments

Comments
 (0)