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:
 - magento/graphql-ce#127: Fixed return value for getGraphQlClient in API-functional tests (by @rogyar)
 - #17572: [Forwardport] Catalog: Add unit tests for Cron classes (by @jignesh-baldha)
 - #17573: [Forwardport] updating lib LESS docs (by @jignesh-baldha)
 - #17571: [Forwardport] Refactor: remove some code duplication (by @arnoudhgz)
 - #17562: Fix wrong return type in StockRegistryInterface API (by @vasilii-b)
 - #17502: [Forwardport] Doesn't work if use date as condition for Catalog Price Rules (by @mage2pratik)
 - #17551: [Forwardport] Fix possible undefined index when caching config data (by @mage2pratik)
 - #17554: [Forwardport] Fix #10687 - Product image roles disappearing (by @eduard13)
 - #16784: [Forwardport] Fix the issue with "Shipping address is not set" exception (by @dmytro-ch)
 - #17499: [Forwardport] Braintree: test coverage (by @ronak2ram)
 - #17610: [Forwardport] Link logo in web setup wizard to back-end base URL (by @arnoudhgz)
 - #17604: [Forwardport] Fix for #15041 Adding a new fieldset to the admin category editor changes the position of the 'General' fieldset (by @jignesh-baldha)
 - #17603: [Forwardport] Braintree: Add unit test for CreditCard/TokenFormatter (by @jignesh-baldha)
 - #17596: Typo in Magento\Cms\Model\Wysiwyg\Images\Storage function resizeFile() (by @eduard13)


Fixed GitHub Issues:
 - #15085: StockRegistryInterface :: getLowStockItems() returns StockStatusCollection instead of StockItemCollection (reported by @jesse-dev) has been fixed in #17562 by @vasilii-b in 2.3-develop branch
   Related commits:
     1. 897e7df

 - #10687: Product image roles randomly disappear (reported by @boxyman) has been fixed in #17554 by @eduard13 in 2.3-develop branch
   Related commits:
     1. 1c74f55

 - #16555: "Shipping address is not set" exception in Multishipping Checkout. (reported by @p-bystritsky) has been fixed in #16784 by @dmytro-ch in 2.3-develop branch
   Related commits:
     1. ab1324e
     2. 7187c2e
     3. 9868428
     4. 2c546c4

 - #13948: Sidebar shortcut to admin dashboard (Magento logo on top left) has no link in web setup wizard (reported by @doctormess) has been fixed in #17610 by @arnoudhgz in 2.3-develop branch
   Related commits:
     1. 43bbdb5

 - #15041: Adding a new fieldset to the admin category editor changes the position of the 'General' fieldset. (reported by @leoquijano) has been fixed in #17604 by @jignesh-baldha in 2.3-develop branch
   Related commits:
     1. b6df8e7

 - #17587: Typo in Magento\Cms\Model\Wysiwyg\Images\Storage function resizeFile($source, $keepRation = true) (reported by @simonworkhouse) has been fixed in #17596 by @eduard13 in 2.3-develop branch
   Related commits:
     1. 9a5bfd3
  • Loading branch information
magento-engcom-team authored Aug 16, 2018
2 parents 03ab0fd + 02e4bf3 commit 1a968e0
Show file tree
Hide file tree
Showing 46 changed files with 755 additions and 130 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;

use Magento\Braintree\Gateway\Config\Config;
use Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker;

/**
* @covers \Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker
*/
class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase
{
/**
* Testable Object
*
* @var AvailabilityChecker
*/
private $availabilityChecker;

/**
* @var Config|\PHPUnit_Framework_MockObject_MockObject
*/
private $configMock;

/**
* Set Up
*
* @return void
*/
protected function setUp()
{
$this->configMock = $this->createMock(Config::class);
$this->availabilityChecker = new AvailabilityChecker($this->configMock);
}

/**
* Test isAvailable method
*
* @dataProvider isAvailableDataProvider
*
* @param bool $isVerify3DSecure
* @param bool $expected
*
* @return void
*/
public function testIsAvailable(bool $isVerify3DSecure, bool $expected)
{
$this->configMock->expects($this->once())->method('isVerify3DSecure')->willReturn($isVerify3DSecure);
$actual = $this->availabilityChecker->isAvailable();
self::assertEquals($expected, $actual);
}

/**
* Data provider for isAvailable method test
*
* @return array
*/
public function isAvailableDataProvider()
{
return [
[true, false],
[false, true],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;

use Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter as CreditCardTokenFormatter;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;

class TokenFormatterTest extends TestCase
{
/**
* @var PaymentTokenInterface|PHPUnit_Framework_MockObject_MockObject
*/
private $paymentTokenMock;

/**
* @var CreditCardTokenFormatter
*/
private $creditCardTokenFormatter;

/**
* @var array
*/
private $tokenDetails = [
'type' => 'visa',
'maskedCC' => '1111************9999',
'expirationDate' => '01-01-2020'
];

/**
* Set Up
*
* @return void
*/
protected function setUp()
{
$this->paymentTokenMock = $this->getMockBuilder(PaymentTokenInterface::class)
->getMockForAbstractClass();

$this->creditCardTokenFormatter = new CreditCardTokenFormatter();
}

/**
* Testing the payment format with a known credit card type
*
* @return void
*/
public function testFormatPaymentTokenWithKnownCardType()
{
$this->tokenDetails['type'] = key(CreditCardTokenFormatter::$baseCardTypes);
$this->paymentTokenMock->expects($this->once())
->method('getTokenDetails')
->willReturn(json_encode($this->tokenDetails));

$formattedString = sprintf(
'%s: %s, %s: %s (%s: %s)',
__('Credit Card'),
reset(CreditCardTokenFormatter::$baseCardTypes),
__('ending'),
$this->tokenDetails['maskedCC'],
__('expires'),
$this->tokenDetails['expirationDate']
);

self::assertEquals(
$formattedString,
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock)
);
}

/**
* Testing the payment format with a unknown credit card type
*
* @return void
*/
public function testFormatPaymentTokenWithUnknownCardType()
{
$this->paymentTokenMock->expects($this->once())
->method('getTokenDetails')
->willReturn(json_encode($this->tokenDetails));

$formattedString = sprintf(
'%s: %s, %s: %s (%s: %s)',
__('Credit Card'),
$this->tokenDetails['type'],
__('ending'),
$this->tokenDetails['maskedCC'],
__('expires'),
$this->tokenDetails['expirationDate']
);

self::assertEquals(
$formattedString,
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock)
);
}

/**
* Testing the payment format with wrong card data
*
* @return void
*/
public function testFormatPaymentTokenWithWrongData()
{
unset($this->tokenDetails['type']);
$this->paymentTokenMock->expects($this->once())
->method('getTokenDetails')
->willReturn(json_encode($this->tokenDetails));
self::expectException('\InvalidArgumentException');

$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Braintree\Test\Unit\Model\InstantPurchase;

use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand;
use Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider;
use Magento\Payment\Gateway\Command\Result\ArrayResult;
use Magento\Vault\Api\Data\PaymentTokenInterface;

/**
* @covers \Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider
*/
class PaymentAdditionalInformationProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* Testable Object
*
* @var PaymentAdditionalInformationProvider
*/
private $paymentAdditionalInformationProvider;

/**
* @var GetPaymentNonceCommand|\PHPUnit_Framework_MockObject_MockObject
*/
private $getPaymentNonceCommandMock;

/**
* @var PaymentTokenInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $paymentTokenMock;

/**
* @var ArrayResult|\PHPUnit_Framework_MockObject_MockObject
*/
private $arrayResultMock;

/**
* Set Up
*
* @return void
*/
protected function setUp()
{
$this->getPaymentNonceCommandMock = $this->createMock(GetPaymentNonceCommand::class);
$this->paymentTokenMock = $this->createMock(PaymentTokenInterface::class);
$this->arrayResultMock = $this->createMock(ArrayResult::class);
$this->paymentAdditionalInformationProvider = new PaymentAdditionalInformationProvider(
$this->getPaymentNonceCommandMock
);
}

/**
* Test getAdditionalInformation method
*
* @return void
*/
public function testGetAdditionalInformation()
{
$customerId = 15;
$publicHash = '3n4b7sn48g';
$paymentMethodNonce = 'test';

$this->paymentTokenMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
$this->paymentTokenMock->expects($this->once())->method('getPublicHash')->willReturn($publicHash);
$this->getPaymentNonceCommandMock->expects($this->once())->method('execute')->with([
PaymentTokenInterface::CUSTOMER_ID => $customerId,
PaymentTokenInterface::PUBLIC_HASH => $publicHash,
])->willReturn($this->arrayResultMock);
$this->arrayResultMock->expects($this->once())->method('get')
->willReturn(['paymentMethodNonce' => $paymentMethodNonce]);

$expected = [
'payment_method_nonce' => $paymentMethodNonce,
];
$actual = $this->paymentAdditionalInformationProvider->getAdditionalInformation($this->paymentTokenMock);
self::assertEquals($expected, $actual);
}
}
Loading

0 comments on commit 1a968e0

Please sign in to comment.