Skip to content

Commit 1cecf51

Browse files
committed
ACP2E-2622: Unable to save changes to phone number in existing order details
- Test coverage added
1 parent 5ca8bb4 commit 1cecf51

File tree

1 file changed

+111
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/**
3+
* Copyright 2023 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Sales\Model\ResourceModel\Order;
18+
19+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
20+
use Magento\Checkout\Test\Fixture\PlaceOrder as PlaceOrderFixture;
21+
use Magento\Checkout\Test\Fixture\SetBillingAddress;
22+
use Magento\Checkout\Test\Fixture\SetDeliveryMethod as SetDeliveryMethodFixture;
23+
use Magento\Checkout\Test\Fixture\SetPaymentMethod as SetPaymentMethodFixture;
24+
use Magento\Checkout\Test\Fixture\SetShippingAddress;
25+
use Magento\Customer\Test\Fixture\Customer;
26+
use Magento\Framework\Exception\LocalizedException;
27+
use Magento\Quote\Test\Fixture\AddProductToCart;
28+
use Magento\Quote\Test\Fixture\CustomerCart;
29+
use Magento\Sales\Api\OrderAddressRepositoryInterface;
30+
use Magento\Sales\Api\OrderRepositoryInterface;
31+
use Magento\TestFramework\Fixture\DataFixture;
32+
use Magento\TestFramework\Fixture\DataFixtureStorage;
33+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
34+
use Magento\TestFramework\Fixture\DbIsolation;
35+
use Magento\TestFramework\Helper\Bootstrap;
36+
use Magento\TestFramework\ObjectManager;
37+
use PHPUnit\Framework\TestCase;
38+
39+
/**
40+
* Test for order address
41+
*
42+
* @magentoAppArea adminhtml
43+
*/
44+
class AddressTest extends TestCase
45+
{
46+
/**
47+
* @var ObjectManager
48+
*/
49+
private $objectManager;
50+
51+
/**
52+
* @var DataFixtureStorage
53+
*/
54+
private $fixtures;
55+
56+
/**
57+
* @var OrderAddressRepositoryInterface
58+
*/
59+
private $orderAddressRepository;
60+
61+
/**
62+
* @var OrderRepositoryInterface
63+
*/
64+
private $orderRepository;
65+
66+
protected function setUp(): void
67+
{
68+
$this->objectManager = Bootstrap::getObjectManager();
69+
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
70+
$this->orderAddressRepository = $this->objectManager->get(OrderAddressRepositoryInterface::class);
71+
$this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
72+
}
73+
74+
/**
75+
* Check to see if leading zeros have been added to the number strings
76+
* in the order address's phone field.
77+
*
78+
* @return void
79+
* @throws LocalizedException
80+
*/
81+
#[
82+
DbIsolation(false),
83+
DataFixture(ProductFixture::class, as: 'product'),
84+
DataFixture(Customer::class, as: 'customer'),
85+
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'quote'),
86+
DataFixture(AddProductToCart::class, ['cart_id' => '$quote.id$', 'product_id' => '$product.id$', 'qty' => 1]),
87+
DataFixture(SetBillingAddress::class, [
88+
'cart_id' => '$quote.id$',
89+
'address' => [
90+
'customer_id' => '$customer.id$',
91+
'telephone' => '009999999999'
92+
]
93+
]),
94+
DataFixture(SetShippingAddress::class, ['cart_id' => '$quote.id$']),
95+
DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$quote.id$']),
96+
DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$quote.id$']),
97+
DataFixture(PlaceOrderFixture::class, ['cart_id' => '$quote.id$'], 'order')
98+
]
99+
public function testOrderAddressUpdateWithTelephone(): void
100+
{
101+
$telephoneValue = '9999999999';
102+
$order = $this->fixtures->get('order');
103+
$address = $this->orderAddressRepository->get($order->getBillingAddressId());
104+
$address->setTelephone($telephoneValue);
105+
$this->orderAddressRepository->save($address);
106+
$updatedOrder = $this->orderRepository->get($order->getId());
107+
$billingAddress = $updatedOrder->getBillingAddress();
108+
$updatedTelephoneValue = $billingAddress->getTelephone();
109+
$this->assertEquals($telephoneValue, $updatedTelephoneValue);
110+
}
111+
}

0 commit comments

Comments
 (0)