Skip to content

Commit 00cda03

Browse files
committed
magento/graphql-ce#480: [Test Coverage] 'GetBillingAddress' functionality
1 parent bd91a20 commit 00cda03

File tree

5 files changed

+64
-13
lines changed

5 files changed

+64
-13
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetBillingAddressTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ protected function setUp()
5353

5454
/**
5555
* @magentoApiDataFixture Magento/Customer/_files/customer.php
56-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
56+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
5757
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
5858
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
5959
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
60+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
6061
*/
6162
public function testGetCartWithBillingAddress()
6263
{
@@ -91,7 +92,7 @@ public function testGetCartWithBillingAddress()
9192

9293
/**
9394
* @magentoApiDataFixture Magento/Customer/_files/three_customers.php
94-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
95+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
9596
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
9697
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
9798
*/
@@ -111,7 +112,7 @@ public function testGetBillingAddressFromAnotherCustomerCart()
111112

112113
/**
113114
* @magentoApiDataFixture Magento/Customer/_files/customer.php
114-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
115+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
115116
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
116117
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
117118
*/

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ protected function setUp()
4646
}
4747

4848
/**
49-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
49+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
5050
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
5151
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
5252
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
53+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
5354
*/
5455
public function testGetCartWithBillingAddress()
5556
{
@@ -59,21 +60,21 @@ public function testGetCartWithBillingAddress()
5960
$expectedBillingAddressData = [
6061
'firstname' => 'John',
6162
'lastname' => 'Smith',
62-
'company' => null,
63+
'company' => 'CompanyName',
6364
'street' => [
64-
'Black str, 48'
65+
'Green str, 67'
6566
],
66-
'city' => 'CityX',
67+
'city' => 'CityM',
6768
'region' => [
6869
'code' => 'AL',
6970
'label' => 'Alabama',
7071
],
71-
'postcode' => '47676',
72+
'postcode' => '75477',
7273
'country' => [
7374
'code' => 'US',
7475
'label' => 'US',
7576
],
76-
'telephone' => '3234676',
77+
'telephone' => '3468676',
7778
'address_type' => 'BILLING',
7879
];
7980

@@ -82,10 +83,11 @@ public function testGetCartWithBillingAddress()
8283

8384
/**
8485
* @magentoApiDataFixture Magento/Customer/_files/customer.php
85-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
86+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
8687
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
8788
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
8889
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
90+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
8991
*/
9092
public function testGetBillingAddressFromAnotherCustomerCart()
9193
{
@@ -100,9 +102,10 @@ public function testGetBillingAddressFromAnotherCustomerCart()
100102
}
101103

102104
/**
103-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
105+
* @magentoApiDataFixture Magento/Catalog/_files/products.php
104106
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
105107
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
108+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
106109
*/
107110
public function testGetBillingAddressIfBillingAddressIsNotSet()
108111
{
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
use Magento\Framework\Api\DataObjectHelper;
9+
use Magento\Quote\Api\Data\AddressInterface;
10+
use Magento\Quote\Api\Data\AddressInterfaceFactory;
11+
use Magento\Quote\Api\BillingAddressManagementInterface;
12+
use Magento\Quote\Model\QuoteFactory;
13+
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
14+
15+
use Magento\TestFramework\Helper\Bootstrap;
16+
17+
/** @var QuoteFactory $quoteFactory */
18+
$quoteFactory = Bootstrap::getObjectManager()->get(QuoteFactory::class);
19+
/** @var QuoteResource $quoteResource */
20+
$quoteResource = Bootstrap::getObjectManager()->get(QuoteResource::class);
21+
/** @var AddressInterfaceFactory $quoteAddressFactory */
22+
$quoteAddressFactory = Bootstrap::getObjectManager()->get(AddressInterfaceFactory::class);
23+
/** @var DataObjectHelper $dataObjectHelper */
24+
$dataObjectHelper = Bootstrap::getObjectManager()->get(DataObjectHelper::class);
25+
/** @var BillingAddressManagementInterface $billingAddressManagement */
26+
$billingAddressManagement = Bootstrap::getObjectManager()->get(BillingAddressManagementInterface::class);
27+
28+
$quoteAddressData = [
29+
AddressInterface::KEY_TELEPHONE => 3468676,
30+
AddressInterface::KEY_POSTCODE => 75477,
31+
AddressInterface::KEY_COUNTRY_ID => 'US',
32+
AddressInterface::KEY_CITY => 'CityM',
33+
AddressInterface::KEY_COMPANY => 'CompanyName',
34+
AddressInterface::KEY_STREET => 'Green str, 67',
35+
AddressInterface::KEY_LASTNAME => 'Smith',
36+
AddressInterface::KEY_FIRSTNAME => 'John',
37+
AddressInterface::KEY_REGION_ID => 1,
38+
];
39+
$quoteAddress = $quoteAddressFactory->create();
40+
$dataObjectHelper->populateWithArray($quoteAddress, $quoteAddressData, AddressInterfaceFactory::class);
41+
42+
$quote = $quoteFactory->create();
43+
$quoteResource->load($quote, 'test_quote', 'reserved_order_id');
44+
$billingAddressManagement->assign($quote->getId(), $quoteAddress);

dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
*/
66
declare(strict_types=1);
77

8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
810
require __DIR__ . '/address_list.php';
911

1012
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
1113

1214
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
13-
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
15+
/** @var ProductRepositoryInterface $productRepository */
16+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
1417

1518
/** @var \Magento\Catalog\Model\Product $product */
1619
$product = $objectManager->create(\Magento\Catalog\Model\Product::class);

dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses_rollback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626

2727
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
28-
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
28+
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
2929

3030
try {
3131
$product = $productRepository->get('simple-product-guest-quote', false, null, true);

0 commit comments

Comments
 (0)