Skip to content

Commit 51cc30b

Browse files
authored
Merge pull request #1592 from magento-tsg/2.1-develop-pr33
Fixed issues: MAGETWO-64521 Impossible to create update with the product MAGETWO-72466 [Backport][2.1.x] PayPal.js error on checkout downloadable product
2 parents a57a612 + e9f6fa6 commit 51cc30b

File tree

9 files changed

+140
-12
lines changed

9 files changed

+140
-12
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ define([
296296
getShippingAddress: function () {
297297
var address = quote.shippingAddress();
298298

299-
if (address.postcode === null) {
299+
if (_.isNull(address.postcode) || _.isUndefined(address.postcode)) {
300300

301301
return {};
302302
}

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
use Magento\TestFramework\Helper\Bootstrap;
1414
use Magento\TestFramework\TestCase\WebapiAbstract;
1515

16+
/**
17+
* Tests Magento\Catalog\Model\Product\Option\Repository.
18+
*/
1619
class ProductCustomOptionRepositoryTest extends WebapiAbstract
1720
{
21+
const SERVICE_NAME = 'catalogProductCustomOptionRepositoryV1';
22+
1823
/**
1924
* @var \Magento\Framework\ObjectManagerInterface
2025
*/
2126
protected $objectManager;
2227

23-
const SERVICE_NAME = 'catalogProductCustomOptionRepositoryV1';
24-
2528
/**
2629
* @var \Magento\Catalog\Model\ProductFactory
2730
*/
@@ -30,19 +33,20 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract
3033
protected function setUp()
3134
{
3235
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
33-
$this->productFactory = $this->objectManager->get('Magento\Catalog\Model\ProductFactory');
36+
$this->productFactory = $this->objectManager->get(\Magento\Catalog\Model\ProductFactory::class);
3437
}
3538

3639
/**
3740
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
3841
* @magentoAppIsolation enabled
42+
* @return void
3943
*/
4044
public function testRemove()
4145
{
4246
$sku = 'simple';
4347
/** @var ProductRepository $productRepository */
4448
$productRepository = $this->objectManager->create(
45-
'Magento\Catalog\Model\ProductRepository'
49+
\Magento\Catalog\Model\ProductRepository::class
4650
);
4751
/** @var \Magento\Catalog\Model\Product $product */
4852
$product = $productRepository->get($sku, false, null, true);
@@ -69,13 +73,14 @@ public function testRemove()
6973
/**
7074
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
7175
* @magentoAppIsolation enabled
76+
* @return void
7277
*/
7378
public function testGet()
7479
{
7580
$productSku = 'simple';
7681
/** @var \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $service */
7782
$service = Bootstrap::getObjectManager()
78-
->get('Magento\Catalog\Api\ProductCustomOptionRepositoryInterface');
83+
->get(\Magento\Catalog\Api\ProductCustomOptionRepositoryInterface::class);
7984
$options = $service->getList('simple');
8085
$option = current($options);
8186
$optionId = $option->getOptionId();
@@ -100,6 +105,7 @@ public function testGet()
100105
/**
101106
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
102107
* @magentoAppIsolation enabled
108+
* @return void
103109
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
104110
*/
105111
public function testGetList()
@@ -144,6 +150,7 @@ public function testGetList()
144150
* @magentoAppIsolation enabled
145151
* @dataProvider optionDataProvider
146152
* @param array $optionData
153+
* @return void
147154
*/
148155
public function testSave($optionData)
149156
{
@@ -174,6 +181,9 @@ public function testSave($optionData)
174181
$this->assertEquals($optionData, $result);
175182
}
176183

184+
/**
185+
* @return array
186+
*/
177187
public function optionDataProvider()
178188
{
179189
$fixtureOptions = [];
@@ -191,6 +201,7 @@ public function optionDataProvider()
191201
* @magentoApiDataFixture Magento/Catalog/_files/product_without_options.php
192202
* @magentoAppIsolation enabled
193203
* @dataProvider optionNegativeDataProvider
204+
* @return void
194205
*/
195206
public function testAddNegative($optionData)
196207
{
@@ -221,6 +232,9 @@ public function testAddNegative($optionData)
221232
$this->_webApiCall($serviceInfo, ['option' => $optionDataPost]);
222233
}
223234

235+
/**
236+
* @return array
237+
*/
224238
public function optionNegativeDataProvider()
225239
{
226240
$fixtureOptions = [];
@@ -237,13 +251,14 @@ public function optionNegativeDataProvider()
237251
/**
238252
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
239253
* @magentoAppIsolation enabled
254+
* @return void
240255
*/
241256
public function testUpdate()
242257
{
243258
$productSku = 'simple';
244259
/** @var ProductRepository $productRepository */
245260
$productRepository = $this->objectManager->create(
246-
'Magento\Catalog\Model\ProductRepository'
261+
\Magento\Catalog\Model\ProductRepository::class
247262
);
248263

249264
$options = $productRepository->get($productSku, true)->getOptions();
@@ -290,6 +305,7 @@ public function testUpdate()
290305

291306
/**
292307
* @param string $optionType
308+
* @return void
293309
*
294310
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
295311
* @magentoAppIsolation enabled
@@ -309,7 +325,7 @@ public function testUpdateOptionAddingNewValue($optionType)
309325

310326
/** @var ProductRepository $productRepository */
311327
$productRepository = $this->objectManager->create(
312-
'Magento\Catalog\Model\ProductRepository'
328+
\Magento\Catalog\Model\ProductRepository::class
313329
);
314330
/** @var \Magento\Catalog\Model\Product $product */
315331
$product = $productRepository->get('simple', false, null, true);
@@ -372,6 +388,9 @@ public function testUpdateOptionAddingNewValue($optionType)
372388
$this->assertEquals(100, $values['sort_order']);
373389
}
374390

391+
/**
392+
* @return array
393+
*/
375394
public function validOptionDataProvider()
376395
{
377396
return [
@@ -388,8 +407,10 @@ public function validOptionDataProvider()
388407
* @dataProvider optionNegativeUpdateDataProvider
389408
* @param array $optionData
390409
* @param string $message
410+
* @param int $exceptionCode
411+
* @return void
391412
*/
392-
public function testUpdateNegative($optionData, $message)
413+
public function testUpdateNegative($optionData, $message, $exceptionCode)
393414
{
394415
$productSku = 'simple';
395416
/** @var ProductRepository $productRepository */
@@ -413,7 +434,7 @@ public function testUpdateNegative($optionData, $message)
413434
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
414435
$this->setExpectedException('SoapFault');
415436
} else {
416-
$this->setExpectedException('Exception', $message, 400);
437+
$this->setExpectedException('Exception', $message, $exceptionCode);
417438
}
418439
$this->_webApiCall($serviceInfo, ['option' => $optionData]);
419440
}

dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_update_negative.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
'max_characters' => 10,
1919
],
2020
'ProductSku should be specified',
21-
]
21+
400,
22+
],
2223
];

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,21 @@
5050
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
5151
<constraint name="Magento\Sales\Test\Constraint\AssertCaptureInCommentsHistory" />
5252
</variation>
53+
<variation name="OnePageCheckoutWithBraintreePaypalTestVariation3" summary="Guest Checkout virtual quote with Braintree PayPal from Cart" ticketId="MAGETWO-80083">
54+
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S2</data>
55+
<data name="products/0" xsi:type="string">catalogProductVirtual::product_50_dollar</data>
56+
<data name="customer/dataset" xsi:type="string">default</data>
57+
<data name="checkoutMethod" xsi:type="string">guest</data>
58+
<data name="prices" xsi:type="array">
59+
<item name="grandTotal" xsi:type="string">50.00</item>
60+
</data>
61+
<data name="payment/method" xsi:type="string">braintree_paypal</data>
62+
<data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_skip_order_review</data>
63+
<data name="status" xsi:type="string">Processing</data>
64+
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
65+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
66+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
67+
<constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" />
68+
</variation>
5369
</testCase>
5470
</config>

dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/PlaceOrderWithPaypalStep.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Braintree\Test\TestStep;
77

88
use Magento\Checkout\Test\Constraint\AssertGrandTotalOrderReview;
9+
use Magento\Checkout\Test\Constraint\AssertBillingAddressAbsentInPayment;
910
use Magento\Checkout\Test\Page\CheckoutOnepage;
1011
use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
1112
use Magento\Mtf\Fixture\FixtureFactory;
@@ -26,6 +27,11 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
2627
*/
2728
private $assertGrandTotalOrderReview;
2829

30+
/**
31+
* @var AssertBillingAddressAbsentInPayment
32+
*/
33+
private $assertBillingAddressAbsentInPayment;
34+
2935
/**
3036
* @var CheckoutOnepageSuccess
3137
*/
@@ -49,6 +55,7 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
4955
/**
5056
* @param CheckoutOnepage $checkoutOnepage
5157
* @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview
58+
* @param AssertBillingAddressAbsentInPayment $assertBillingAddressAbsentInPayment
5259
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess
5360
* @param FixtureFactory $fixtureFactory
5461
* @param array $products
@@ -57,13 +64,15 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
5764
public function __construct(
5865
CheckoutOnepage $checkoutOnepage,
5966
AssertGrandTotalOrderReview $assertGrandTotalOrderReview,
67+
AssertBillingAddressAbsentInPayment $assertBillingAddressAbsentInPayment,
6068
CheckoutOnepageSuccess $checkoutOnepageSuccess,
6169
FixtureFactory $fixtureFactory,
6270
array $products,
6371
array $prices = []
6472
) {
6573
$this->checkoutOnepage = $checkoutOnepage;
6674
$this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview;
75+
$this->assertBillingAddressAbsentInPayment = $assertBillingAddressAbsentInPayment;
6776
$this->checkoutOnepageSuccess = $checkoutOnepageSuccess;
6877
$this->fixtureFactory = $fixtureFactory;
6978
$this->products = $products;
@@ -78,6 +87,9 @@ public function run()
7887
if (isset($this->prices['grandTotal'])) {
7988
$this->assertGrandTotalOrderReview->processAssert($this->checkoutOnepage, $this->prices['grandTotal']);
8089
}
90+
91+
$this->assertBillingAddressAbsentInPayment->processAssert($this->checkoutOnepage);
92+
8193
$parentWindow = $this->checkoutOnepage->getPaymentBlock()
8294
->getSelectedPaymentMethodBlock()
8395
->clickPayWithPaypal();

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class Login extends Form
4949
*/
5050
protected $loadingMask = '.loading-mask';
5151

52+
/**
53+
* Selector for checkout email input.
54+
*
55+
* @var string
56+
*/
57+
private $emailSelector = '[name="username"]';
58+
5259
/**
5360
* Select how to perform checkout whether guest or registered customer.
5461
*
@@ -90,6 +97,18 @@ public function loginCustomer(FixtureInterface $customer)
9097
$this->waitForElementNotVisible($this->loadingMask);
9198
}
9299

100+
/**
101+
* Fill required fields for guest checkout.
102+
*
103+
* @param FixtureInterface $customer
104+
* @return void
105+
*/
106+
public function fillGuestFields(FixtureInterface $customer)
107+
{
108+
$this->_rootElement->find($this->emailSelector)
109+
->setValue($customer->getEmail());
110+
}
111+
93112
/**
94113
* Click continue on checkout method block.
95114
*
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Test\Constraint;
7+
8+
use Magento\Checkout\Test\Page\CheckoutOnepage;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
11+
/**
12+
* Assert billing address is not present in selected payment method.
13+
*/
14+
class AssertBillingAddressAbsentInPayment extends AbstractConstraint
15+
{
16+
/**
17+
* Assert billing address is not present in selected payment method.
18+
*
19+
* @param CheckoutOnepage $checkoutOnepage
20+
* @return void
21+
*/
22+
public function processAssert(CheckoutOnepage $checkoutOnepage)
23+
{
24+
\PHPUnit_Framework_Assert::assertFalse(
25+
$checkoutOnepage->getPaymentBlock()
26+
->getSelectedPaymentMethodBlock()
27+
->getBillingBlock()
28+
->isVisible(),
29+
'Billing address is present in payment method'
30+
);
31+
}
32+
33+
/**
34+
* Returns string representation of successful assertion.
35+
*
36+
* @return string
37+
*/
38+
public function toString()
39+
{
40+
return 'Billing address is absent in payment method';
41+
}
42+
}

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectCheckoutMethodStep.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,33 @@ class SelectCheckoutMethodStep implements TestStepInterface
4444
*/
4545
protected $logoutCustomerOnFrontend;
4646

47+
/**
48+
* Shipping carrier and method.
49+
*
50+
* @var array
51+
*/
52+
private $shipping;
53+
4754
/**
4855
* @constructor
4956
* @param CheckoutOnepage $checkoutOnepage
5057
* @param Customer $customer
5158
* @param LogoutCustomerOnFrontendStep $logoutCustomerOnFrontend
5259
* @param string $checkoutMethod
60+
* @param array $shipping
5361
*/
5462
public function __construct(
5563
CheckoutOnepage $checkoutOnepage,
5664
Customer $customer,
5765
LogoutCustomerOnFrontendStep $logoutCustomerOnFrontend,
58-
$checkoutMethod
66+
$checkoutMethod,
67+
array $shipping = []
5968
) {
6069
$this->checkoutOnepage = $checkoutOnepage;
6170
$this->customer = $customer;
6271
$this->logoutCustomerOnFrontend = $logoutCustomerOnFrontend;
6372
$this->checkoutMethod = $checkoutMethod;
73+
$this->shipping = $shipping;
6474
}
6575

6676
/**
@@ -72,6 +82,8 @@ public function run()
7282
{
7383
if ($this->checkoutMethod === 'login') {
7484
$this->checkoutOnepage->getLoginBlock()->loginCustomer($this->customer);
85+
} elseif (($this->checkoutMethod === 'guest') && empty($this->shipping)) {
86+
$this->checkoutOnepage->getLoginBlock()->fillGuestFields($this->customer);
7587
}
7688
}
7789

dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
<argument name="severity" xsi:type="string">middle</argument>
1212
</arguments>
1313
</type>
14+
<type name="Magento\Checkout\Test\Constraint\AssertBillingAddressAbsentInPayment">
15+
<arguments>
16+
<argument name="severity" xsi:type="string">S2</argument>
17+
</arguments>
18+
</type>
1419
</config>

0 commit comments

Comments
 (0)