Skip to content

Commit 1243b1b

Browse files
Merge branch 'ACQE-8551' into ACQE-functional-deployment-v4-1
2 parents 34d5647 + 06c1529 commit 1243b1b

File tree

1 file changed

+118
-2
lines changed

1 file changed

+118
-2
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
6+
67
declare(strict_types=1);
78

89
namespace Magento\GraphQl\Quote\Guest;
@@ -15,6 +16,9 @@
1516
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
1617
use Magento\TestFramework\Helper\Bootstrap;
1718
use Magento\TestFramework\TestCase\GraphQlAbstract;
19+
use Magento\TestFramework\Fixture\Config;
20+
use Magento\TestFramework\Fixture\DataFixture;
21+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1822

1923
/**
2024
* End to checkout tests for guest
@@ -86,6 +90,32 @@ public function testCheckoutWorkflow()
8690
$this->placeOrder($cartId);
8791
}
8892

93+
/**
94+
* Test checkout workflow with null second street in shipping address
95+
* Validates that null values in street array are properly filtered and don't cause errors
96+
*/
97+
#[
98+
Config("checkout/options/guest_checkout", "1", "store", "default"),
99+
DataFixture(
100+
ProductFixture::class,
101+
['price' => 1, 'name' => 'simple1', 'sku' => 'simple1'],
102+
'simple1'
103+
)
104+
]
105+
public function testCheckoutWithNullSecondStreetInShippingAddress()
106+
{
107+
$cartId = $this->createEmptyCart();
108+
$this->setGuestEmailOnCart($cartId);
109+
$this->addProductToCart($cartId, 1, $this->findProduct());
110+
111+
$shippingMethod = $this->setAndVerifyShippingAddressWithNullSecondStreet($cartId);
112+
113+
$this->setBillingAddress($cartId);
114+
$paymentMethod = $this->setShippingMethod($cartId, $shippingMethod);
115+
$this->setPaymentMethod($cartId, $paymentMethod);
116+
$this->placeOrder($cartId);
117+
}
118+
89119
/**
90120
* @return string
91121
*/
@@ -397,6 +427,92 @@ private function placeOrder(string $cartId): void
397427
self::assertNotEmpty($response['placeOrder']['order']['order_number']);
398428
}
399429

430+
/**
431+
* Set shipping address with null second street in address
432+
*
433+
* @param string $cartId
434+
* @return array
435+
*/
436+
private function setAndVerifyShippingAddressWithNullSecondStreet(string $cartId): array
437+
{
438+
$query = <<<QUERY
439+
mutation {
440+
setShippingAddressesOnCart(
441+
input: {
442+
cart_id: "$cartId"
443+
shipping_addresses: [
444+
{
445+
address: {
446+
firstname: "B"
447+
lastname: "C"
448+
street: ["Lorem ipsum dolor sit ame", null]
449+
city: "PARIS"
450+
postcode: "56590"
451+
country_code: "FR"
452+
telephone: "0601020304"
453+
save_in_address_book: false
454+
}
455+
}
456+
]
457+
}
458+
) {
459+
cart {
460+
shipping_addresses {
461+
firstname
462+
lastname
463+
company
464+
street
465+
city
466+
postcode
467+
country {
468+
code
469+
label
470+
}
471+
telephone
472+
available_shipping_methods {
473+
carrier_code
474+
method_code
475+
amount {
476+
value
477+
}
478+
}
479+
}
480+
}
481+
}
482+
}
483+
QUERY;
484+
485+
$response = $this->graphQlMutation($query);
486+
487+
$this->assertArrayHasKey('setShippingAddressesOnCart', $response);
488+
$this->assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
489+
$this->assertArrayHasKey('shipping_addresses', $response['setShippingAddressesOnCart']['cart']);
490+
$this->assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
491+
492+
$shippingAddress = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
493+
494+
$this->assertEquals('B', $shippingAddress['firstname']);
495+
$this->assertEquals('C', $shippingAddress['lastname']);
496+
$this->assertNull($shippingAddress['company']);
497+
$this->assertEquals(['Lorem ipsum dolor sit ame'], $shippingAddress['street']);
498+
$this->assertEquals('PARIS', $shippingAddress['city']);
499+
$this->assertEquals('56590', $shippingAddress['postcode']);
500+
$this->assertEquals('FR', $shippingAddress['country']['code']);
501+
$this->assertEquals('FR', $shippingAddress['country']['label']);
502+
$this->assertEquals('0601020304', $shippingAddress['telephone']);
503+
504+
$this->assertArrayHasKey('available_shipping_methods', $shippingAddress);
505+
$this->assertGreaterThan(0, count($shippingAddress['available_shipping_methods']));
506+
507+
$availableShippingMethod = current($shippingAddress['available_shipping_methods']);
508+
$this->assertArrayHasKey('carrier_code', $availableShippingMethod);
509+
$this->assertNotEmpty($availableShippingMethod['carrier_code']);
510+
$this->assertArrayHasKey('method_code', $availableShippingMethod);
511+
$this->assertNotEmpty($availableShippingMethod['method_code']);
512+
513+
return $availableShippingMethod;
514+
}
515+
400516
protected function tearDown(): void
401517
{
402518
$this->deleteQuote();

0 commit comments

Comments
 (0)