Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #16909: Stabilize Travis CI integration tests suite (by @ishakhsuvarov)
 - #16879: [Port 2.3] Captcha: Added unit test for CheckGuestCheckoutObserver (by @rogyar)
 - #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)
 - #16603: [Forwardport] Fix error in payment void method (by @gelanivishal)
 - magento-engcom/import-export-improvements#109: magento-engcom/import-export-improvements#64: fix issue with Export Type UI (by @dmanners)
 - #16596: [Forwardport] Incorrect value NULL was passed to DataObject constructor. It caused � (by @gelanivishal)
 - #16518: [Forwardport] Use constant time string comparison in FormKey validator (by @gelanivishal)


Fixed GitHub Issues:
 - #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

 - #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

 - #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 #16603 by @gelanivishal in 2.3-develop branch
   Related commits:
     1. a1f5fa5
  • Loading branch information
magento-engcom-team authored Jul 19, 2018
2 parents f54386d + a77426d commit 6200e46
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 16 deletions.
10 changes: 7 additions & 3 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,14 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = ''
{
try {
$response = $this->getResponse();
if ($voidPayment && $response->getXTransId() && strtoupper($response->getXType())
== self::REQUEST_TYPE_AUTH_ONLY
if ($voidPayment
&& $response->getXTransId()
&& strtoupper($response->getXType()) == self::REQUEST_TYPE_AUTH_ONLY
) {
$order->getPayment()->setTransactionId(null)->setParentTransactionId($response->getXTransId())->void();
$order->getPayment()
->setTransactionId(null)
->setParentTransactionId($response->getXTransId())
->void($response);
}
$order->registerCancellation($message)->save();
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Captcha\Test\Unit\Observer;

use Magento\Captcha\Model\DefaultModel as CaptchaModel;
use Magento\Captcha\Observer\CheckGuestCheckoutObserver;
use Magento\Captcha\Helper\Data as CaptchaDataHelper;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ActionFlag;
use Magento\Captcha\Observer\CaptchaStringResolver;
use Magento\Checkout\Model\Type\Onepage;
use Magento\Framework\App\Request\Http;
use Magento\Framework\App\Response\Http as HttpResponse;
use Magento\Framework\Event\Observer;
use Magento\Framework\Json\Helper\Data as JsonHelper;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Quote\Model\Quote;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CheckGuestCheckoutObserverTest extends \PHPUnit\Framework\TestCase
{
const FORM_ID = 'guest_checkout';

/**
* @var CheckGuestCheckoutObserver
*/
private $checkGuestCheckoutObserver;

/**
* @var ObjectManager
*/
private $objectManager;

/**
* @var Observer
*/
private $observer;

/**
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
*/
private $responseMock;

/**
* @var HttpResponse|\PHPUnit_Framework_MockObject_MockObject
*/
private $requestMock;

/**
* @var ActionFlag|\PHPUnit_Framework_MockObject_MockObject
*/
private $actionFlagMock;

/**
* @var CaptchaStringResolver|\PHPUnit_Framework_MockObject_MockObject
*/
private $captchaStringResolverMock;

/**
* @var JsonHelper|\PHPUnit_Framework_MockObject_MockObject
*/
private $jsonHelperMock;

/**
* @var CaptchaModel|\PHPUnit_Framework_MockObject_MockObject
*/
private $captchaModelMock;

/**
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
*/
private $quoteModelMock;

/**
* @var Action|\PHPUnit_Framework_MockObject_MockObject
*/
private $controllerMock;

protected function setUp()
{
$onepageModelTypeMock = $this->createMock(Onepage::class);
$captchaHelperMock = $this->createMock(CaptchaDataHelper::class);
$this->objectManager = new ObjectManager($this);
$this->actionFlagMock = $this->createMock(ActionFlag::class);
$this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
$this->captchaModelMock = $this->createMock(CaptchaModel::class);
$this->quoteModelMock = $this->createMock(Quote::class);
$this->controllerMock = $this->createMock(Action::class);
$this->requestMock = $this->createMock(Http::class);
$this->responseMock = $this->createMock(HttpResponse::class);
$this->observer = new Observer(['controller_action' => $this->controllerMock]);
$this->jsonHelperMock = $this->createMock(JsonHelper::class);

$this->checkGuestCheckoutObserver = $this->objectManager->getObject(
CheckGuestCheckoutObserver::class,
[
'helper' => $captchaHelperMock,
'actionFlag' => $this->actionFlagMock,
'captchaStringResolver' => $this->captchaStringResolverMock,
'typeOnepage' => $onepageModelTypeMock,
'jsonHelper' => $this->jsonHelperMock
]
);

$captchaHelperMock->expects($this->once())
->method('getCaptcha')
->with(self::FORM_ID)
->willReturn($this->captchaModelMock);
$onepageModelTypeMock->expects($this->once())
->method('getQuote')
->willReturn($this->quoteModelMock);
}

public function testCheckGuestCheckoutForRegister()
{
$this->quoteModelMock->expects($this->once())
->method('getCheckoutMethod')
->willReturn(Onepage::METHOD_REGISTER);
$this->captchaModelMock->expects($this->never())
->method('isRequired');

$this->checkGuestCheckoutObserver->execute($this->observer);
}

public function testCheckGuestCheckoutWithNoCaptchaRequired()
{
$this->quoteModelMock->expects($this->once())
->method('getCheckoutMethod')
->willReturn(Onepage::METHOD_GUEST);
$this->captchaModelMock->expects($this->once())
->method('isRequired')
->willReturn(false);
$this->captchaModelMock->expects($this->never())
->method('isCorrect');

$this->checkGuestCheckoutObserver->execute($this->observer);
}

public function testCheckGuestCheckoutWithIncorrectCaptcha()
{
$captchaValue = 'some_word';
$encodedJsonValue = '{}';

$this->quoteModelMock->expects($this->once())
->method('getCheckoutMethod')
->willReturn(Onepage::METHOD_GUEST);
$this->captchaModelMock->expects($this->once())
->method('isRequired')
->willReturn(true);
$this->controllerMock->expects($this->once())
->method('getRequest')
->willReturn($this->requestMock);
$this->controllerMock->expects($this->once())
->method('getResponse')
->willReturn($this->responseMock);
$this->controllerMock->expects($this->once())
->method('getResponse')
->willReturn($this->responseMock);
$this->captchaStringResolverMock->expects($this->once())
->method('resolve')
->with($this->requestMock, self::FORM_ID)
->willReturn($captchaValue);
$this->captchaModelMock->expects($this->once())
->method('isCorrect')
->with($captchaValue)
->willReturn(false);
$this->actionFlagMock->expects($this->once())
->method('set')
->with('', Action::FLAG_NO_DISPATCH, true);
$this->jsonHelperMock->expects($this->once())
->method('jsonEncode')
->willReturn($encodedJsonValue);
$this->responseMock->expects($this->once())
->method('representJson')
->with($encodedJsonValue);

$this->checkGuestCheckoutObserver->execute($this->observer);
}

public function testCheckGuestCheckoutWithCorrectCaptcha()
{
$this->quoteModelMock->expects($this->once())
->method('getCheckoutMethod')
->willReturn(Onepage::METHOD_GUEST);
$this->captchaModelMock->expects($this->once())
->method('isRequired')
->willReturn(true);
$this->controllerMock->expects($this->once())
->method('getRequest')
->willReturn($this->requestMock);
$this->captchaStringResolverMock->expects($this->once())
->method('resolve')
->with($this->requestMock, self::FORM_ID)
->willReturn('some_word');
$this->captchaModelMock->expects($this->once())
->method('isCorrect')
->with('some_word')
->willReturn(true);
$this->actionFlagMock->expects($this->never())
->method('set');

$this->checkGuestCheckoutObserver->execute($this->observer);
}
}
4 changes: 4 additions & 0 deletions app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public function join(FieldNode $fieldNode, AbstractCollection $collection) : voi

/** @var FieldNode $field */
foreach ($query as $field) {
if ($field->kind === 'InlineFragment') {
continue;
}

if (!$collection->isAttributeAdded($field->name->value)) {
$collection->addAttributeToSelect($field->name->value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public function calculate(FieldNode $fieldNode) : int
$depth = count($selections) ? 1 : 0;
$childrenDepth = [0];
foreach ($selections as $node) {
if ($node->kind === 'InlineFragment') {
continue;
}

$childrenDepth[] = $this->calculate($node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function calculate(int $rootCategoryId) : int
{
$connection = $this->resourceConnection->getConnection();
$select = $connection->select()
->from($connection->getTableName('catalog_category_entity'), 'level')
->from($this->resourceConnection->getTableName('catalog_category_entity'), 'level')
->where($this->resourceCategory->getLinkField() . " = ?", $rootCategoryId);
return (int) $connection->fetchOne($select);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
class CategoryTree
{
/**
* In depth we need to calculate only children nodes, so 2 first wrapped nodes should be ignored
* In depth we need to calculate only children nodes, so the first wrapped node should be ignored
*/
const DEPTH_OFFSET = 2;
const DEPTH_OFFSET = 1;

/**
* @var CollectionFactory
Expand Down Expand Up @@ -143,6 +143,10 @@ private function joinAttributesRecursively(Collection $collection, FieldNode $fi

/** @var FieldNode $node */
foreach ($subSelection as $node) {
if ($node->kind === 'InlineFragment') {
continue;
}

$this->joinAttributesRecursively($collection, $node);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ require([
this.modifyFilterGrid();
}
} else {
this.previousGridEntity = '';
$('export_filter_container').hide();
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Wishlist/Model/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public function getProductUrl()
public function getBuyRequest()
{
$option = $this->getOptionByCode('info_buyRequest');
$initialData = $option ? $this->serializer->unserialize($option->getValue()) : null;
$initialData = $option ? $this->serializer->unserialize($option->getValue()) : [];

if ($initialData instanceof \Magento\Framework\DataObject) {
$initialData = $initialData->getData();
Expand Down
Loading

0 comments on commit 6200e46

Please sign in to comment.