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

Commit 5368e01

Browse files
committed
Merge remote-tracking branch 'upstream/2.3-develop' into sku-uniqueness
2 parents 0da8906 + 7fac89a commit 5368e01

File tree

167 files changed

+2792
-868
lines changed

Some content is hidden

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

167 files changed

+2792
-868
lines changed

app/bootstrap.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@
5454
&& isset($_SERVER['HTTP_ACCEPT'])
5555
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
5656
) {
57-
\Magento\Framework\Profiler::applyConfig(
58-
(isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])) ? $_SERVER['MAGE_PROFILER'] : trim(file_get_contents(BP . '/var/profiler.flag')),
57+
$profilerConfig = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
58+
? $_SERVER['MAGE_PROFILER']
59+
: trim(file_get_contents(BP . '/var/profiler.flag'));
60+
61+
if ($profilerConfig) {
62+
$profilerConfig = json_decode($profilerConfig, true) ?: $profilerConfig;
63+
}
64+
65+
Magento\Framework\Profiler::applyConfig(
66+
$profilerConfig,
5967
BP,
6068
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
6169
);

app/code/Magento/AdminNotification/Observer/PredispatchAdminActionControllerObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
}
3838

3939
/**
40-
* Predispath admin action controller
40+
* Predispatch admin action controller
4141
*
4242
* @param \Magento\Framework\Event\Observer $observer
4343
* @return void

app/code/Magento/Braintree/Test/Mftf/ActionGroup/AdminUserActionGroup.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</actionGroup>
1818

1919
<!--Create new user with specified role-->
20-
<actionGroup name="AdminCreateUser">
20+
<actionGroup name="AdminCreateUserAction">
2121
<click selector="{{AdminCreateUserSection.create}}" stepKey="clickToCreateNewUser"/>
2222
<waitForPageLoad stepKey="waitForNewUserPageLoad" time="10"/>
2323
<fillField selector="{{AdminCreateUserSection.usernameTextField}}" userInput="{{NewAdmin.username}}" stepKey="enterUserName" />
@@ -53,4 +53,4 @@
5353
<see userInput="You deleted the user." stepKey="seeSuccessMessage" />
5454
</actionGroup>
5555

56-
</actionGroups>
56+
</actionGroups>

app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1111
<test name="CreateAnAdminOrderUsingBraintreePaymentTest1">
1212
<annotations>
1313
<features value="Backend"/>
@@ -17,6 +17,9 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-93677"/>
1919
<group value="braintree"/>
20+
<skip>
21+
<issueId value="MQE-1187" />
22+
</skip>
2023
</annotations>
2124

2225

@@ -42,7 +45,7 @@
4245

4346
<!--Create New User With Specific Role-->
4447
<actionGroup ref="GoToAllUsers" stepKey="GoToAllUsers"/>
45-
<actionGroup ref="AdminCreateUser" stepKey="AdminCreateNewUser"/>
48+
<actionGroup ref="AdminCreateUserAction" stepKey="AdminCreateNewUser"/>
4649

4750
<!--SignOut-->
4851
<actionGroup ref="SignOut" stepKey="signOutFromAdmin"/>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;
9+
10+
use Magento\Braintree\Gateway\Config\Config;
11+
use Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker;
12+
13+
/**
14+
* @covers \Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker
15+
*/
16+
class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase
17+
{
18+
/**
19+
* Testable Object
20+
*
21+
* @var AvailabilityChecker
22+
*/
23+
private $availabilityChecker;
24+
25+
/**
26+
* @var Config|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
private $configMock;
29+
30+
/**
31+
* Set Up
32+
*
33+
* @return void
34+
*/
35+
protected function setUp()
36+
{
37+
$this->configMock = $this->createMock(Config::class);
38+
$this->availabilityChecker = new AvailabilityChecker($this->configMock);
39+
}
40+
41+
/**
42+
* Test isAvailable method
43+
*
44+
* @dataProvider isAvailableDataProvider
45+
*
46+
* @param bool $isVerify3DSecure
47+
* @param bool $expected
48+
*
49+
* @return void
50+
*/
51+
public function testIsAvailable(bool $isVerify3DSecure, bool $expected)
52+
{
53+
$this->configMock->expects($this->once())->method('isVerify3DSecure')->willReturn($isVerify3DSecure);
54+
$actual = $this->availabilityChecker->isAvailable();
55+
self::assertEquals($expected, $actual);
56+
}
57+
58+
/**
59+
* Data provider for isAvailable method test
60+
*
61+
* @return array
62+
*/
63+
public function isAvailableDataProvider()
64+
{
65+
return [
66+
[true, false],
67+
[false, true],
68+
];
69+
}
70+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;
9+
10+
use Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter as CreditCardTokenFormatter;
11+
use Magento\Vault\Api\Data\PaymentTokenInterface;
12+
use PHPUnit\Framework\TestCase;
13+
use PHPUnit_Framework_MockObject_MockObject;
14+
15+
class TokenFormatterTest extends TestCase
16+
{
17+
/**
18+
* @var PaymentTokenInterface|PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $paymentTokenMock;
21+
22+
/**
23+
* @var CreditCardTokenFormatter
24+
*/
25+
private $creditCardTokenFormatter;
26+
27+
/**
28+
* @var array
29+
*/
30+
private $tokenDetails = [
31+
'type' => 'visa',
32+
'maskedCC' => '1111************9999',
33+
'expirationDate' => '01-01-2020'
34+
];
35+
36+
/**
37+
* Set Up
38+
*
39+
* @return void
40+
*/
41+
protected function setUp()
42+
{
43+
$this->paymentTokenMock = $this->getMockBuilder(PaymentTokenInterface::class)
44+
->getMockForAbstractClass();
45+
46+
$this->creditCardTokenFormatter = new CreditCardTokenFormatter();
47+
}
48+
49+
/**
50+
* Testing the payment format with a known credit card type
51+
*
52+
* @return void
53+
*/
54+
public function testFormatPaymentTokenWithKnownCardType()
55+
{
56+
$this->tokenDetails['type'] = key(CreditCardTokenFormatter::$baseCardTypes);
57+
$this->paymentTokenMock->expects($this->once())
58+
->method('getTokenDetails')
59+
->willReturn(json_encode($this->tokenDetails));
60+
61+
$formattedString = sprintf(
62+
'%s: %s, %s: %s (%s: %s)',
63+
__('Credit Card'),
64+
reset(CreditCardTokenFormatter::$baseCardTypes),
65+
__('ending'),
66+
$this->tokenDetails['maskedCC'],
67+
__('expires'),
68+
$this->tokenDetails['expirationDate']
69+
);
70+
71+
self::assertEquals(
72+
$formattedString,
73+
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock)
74+
);
75+
}
76+
77+
/**
78+
* Testing the payment format with a unknown credit card type
79+
*
80+
* @return void
81+
*/
82+
public function testFormatPaymentTokenWithUnknownCardType()
83+
{
84+
$this->paymentTokenMock->expects($this->once())
85+
->method('getTokenDetails')
86+
->willReturn(json_encode($this->tokenDetails));
87+
88+
$formattedString = sprintf(
89+
'%s: %s, %s: %s (%s: %s)',
90+
__('Credit Card'),
91+
$this->tokenDetails['type'],
92+
__('ending'),
93+
$this->tokenDetails['maskedCC'],
94+
__('expires'),
95+
$this->tokenDetails['expirationDate']
96+
);
97+
98+
self::assertEquals(
99+
$formattedString,
100+
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock)
101+
);
102+
}
103+
104+
/**
105+
* Testing the payment format with wrong card data
106+
*
107+
* @return void
108+
*/
109+
public function testFormatPaymentTokenWithWrongData()
110+
{
111+
unset($this->tokenDetails['type']);
112+
$this->paymentTokenMock->expects($this->once())
113+
->method('getTokenDetails')
114+
->willReturn(json_encode($this->tokenDetails));
115+
self::expectException('\InvalidArgumentException');
116+
117+
$this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock);
118+
}
119+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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\Braintree\Test\Unit\Model\InstantPurchase;
9+
10+
use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand;
11+
use Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider;
12+
use Magento\Payment\Gateway\Command\Result\ArrayResult;
13+
use Magento\Vault\Api\Data\PaymentTokenInterface;
14+
15+
/**
16+
* @covers \Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider
17+
*/
18+
class PaymentAdditionalInformationProviderTest extends \PHPUnit\Framework\TestCase
19+
{
20+
/**
21+
* Testable Object
22+
*
23+
* @var PaymentAdditionalInformationProvider
24+
*/
25+
private $paymentAdditionalInformationProvider;
26+
27+
/**
28+
* @var GetPaymentNonceCommand|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $getPaymentNonceCommandMock;
31+
32+
/**
33+
* @var PaymentTokenInterface|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
private $paymentTokenMock;
36+
37+
/**
38+
* @var ArrayResult|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
private $arrayResultMock;
41+
42+
/**
43+
* Set Up
44+
*
45+
* @return void
46+
*/
47+
protected function setUp()
48+
{
49+
$this->getPaymentNonceCommandMock = $this->createMock(GetPaymentNonceCommand::class);
50+
$this->paymentTokenMock = $this->createMock(PaymentTokenInterface::class);
51+
$this->arrayResultMock = $this->createMock(ArrayResult::class);
52+
$this->paymentAdditionalInformationProvider = new PaymentAdditionalInformationProvider(
53+
$this->getPaymentNonceCommandMock
54+
);
55+
}
56+
57+
/**
58+
* Test getAdditionalInformation method
59+
*
60+
* @return void
61+
*/
62+
public function testGetAdditionalInformation()
63+
{
64+
$customerId = 15;
65+
$publicHash = '3n4b7sn48g';
66+
$paymentMethodNonce = 'test';
67+
68+
$this->paymentTokenMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
69+
$this->paymentTokenMock->expects($this->once())->method('getPublicHash')->willReturn($publicHash);
70+
$this->getPaymentNonceCommandMock->expects($this->once())->method('execute')->with([
71+
PaymentTokenInterface::CUSTOMER_ID => $customerId,
72+
PaymentTokenInterface::PUBLIC_HASH => $publicHash,
73+
])->willReturn($this->arrayResultMock);
74+
$this->arrayResultMock->expects($this->once())->method('get')
75+
->willReturn(['paymentMethodNonce' => $paymentMethodNonce]);
76+
77+
$expected = [
78+
'payment_method_nonce' => $paymentMethodNonce,
79+
];
80+
$actual = $this->paymentAdditionalInformationProvider->getAdditionalInformation($this->paymentTokenMock);
81+
self::assertEquals($expected, $actual);
82+
}
83+
}

0 commit comments

Comments
 (0)