7
7
8
8
namespace Magento \Customer \Controller \Adminhtml \Index ;
9
9
10
+ use Magento \Customer \Api \AddressRepositoryInterface ;
10
11
use Magento \Customer \Api \CustomerMetadataInterface ;
11
12
use Magento \Customer \Api \CustomerRepositoryInterface ;
12
13
use Magento \Customer \Api \Data \CustomerInterface ;
14
+ use Magento \Customer \Observer \AfterAddressSaveObserver ;
13
15
use Magento \Eav \Model \AttributeRepository ;
14
16
use Magento \Framework \App \Request \Http as HttpRequest ;
15
17
use Magento \Framework \ObjectManagerInterface ;
18
+ use Magento \Framework \Registry ;
16
19
use Magento \Framework \Serialize \SerializerInterface ;
17
20
use Magento \Store \Api \WebsiteRepositoryInterface ;
18
21
use Magento \TestFramework \Helper \Bootstrap ;
23
26
*
24
27
* @magentoAppArea adminhtml
25
28
* @magentoDbIsolation enabled
29
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26
30
*/
27
31
class InlineEditTest extends AbstractBackendController
28
32
{
@@ -41,6 +45,12 @@ class InlineEditTest extends AbstractBackendController
41
45
/** @var AttributeRepository */
42
46
private $ attributeRepository ;
43
47
48
+ /** @var AddressRepositoryInterface */
49
+ private $ addressRepository ;
50
+
51
+ /** @var Registry */
52
+ private $ coreRegistry ;
53
+
44
54
/**
45
55
* @inheritdoc
46
56
*/
@@ -53,6 +63,8 @@ protected function setUp()
53
63
$ this ->json = $ this ->objectManager ->get (SerializerInterface::class);
54
64
$ this ->websiteRepository = $ this ->objectManager ->get (WebsiteRepositoryInterface::class);
55
65
$ this ->attributeRepository = $ this ->objectManager ->get (AttributeRepository::class);
66
+ $ this ->addressRepository = $ this ->objectManager ->get (AddressRepositoryInterface::class);
67
+ $ this ->coreRegistry = Bootstrap::getObjectManager ()->get (Registry::class);
56
68
}
57
69
58
70
/**
@@ -121,6 +133,53 @@ public function inlineEditParametersDataProvider(): array
121
133
];
122
134
}
123
135
136
+ /**
137
+ * Customer group should not change after saving customer via customer grid because of disabled address validation
138
+ *
139
+ * @magentoConfigFixture current_store customer/create_account/auto_group_assign 1
140
+ * @magentoConfigFixture current_store customer/create_account/viv_invalid_group 2
141
+ * @magentoDataFixture Magento/Customer/_files/customer_one_address.php
142
+ *
143
+ * @return void
144
+ */
145
+ public function testInlineEditActionWithAddress (): void
146
+ {
147
+ $ customer = $ this ->getCustomer ();
148
+ $ params = [
149
+ 'items ' => [
150
+ $ customer ->getId () => []
151
+ ],
152
+ 'isAjax ' => true ,
153
+ ];
154
+ $ actual = $ this ->performInlineEditRequest ($ params );
155
+ $ updatedCustomer = $ this ->customerRepository ->get ('customer_one_address@test.com ' );
156
+ $ this ->assertEmpty ($ actual ['messages ' ]);
157
+ $ this ->assertFalse ($ actual ['error ' ]);
158
+ $ this ->assertEquals (
159
+ $ customer ->getGroupId (),
160
+ $ updatedCustomer ->getGroupId (),
161
+ 'Customer group was changed! '
162
+ );
163
+ }
164
+
165
+ /**
166
+ * Change customer address with setting country from EU and setting VAT number
167
+ *
168
+ * @return CustomerInterface
169
+ */
170
+ private function getCustomer (): CustomerInterface
171
+ {
172
+ $ customer = $ this ->customerRepository ->get ('customer_one_address@test.com ' );
173
+ $ address = $ this ->addressRepository ->getById ((int )$ customer ->getDefaultShipping ());
174
+ $ address ->setVatId (12345 );
175
+ $ address ->setCountryId ('DE ' );
176
+ $ address ->setRegionId (0 );
177
+ $ this ->addressRepository ->save ($ address );
178
+ $ this ->coreRegistry ->unregister (AfterAddressSaveObserver::VIV_PROCESSED_FLAG );
179
+ //return customer after address repository save
180
+ return $ this ->customerRepository ->get ('customer_one_address@test.com ' );
181
+ }
182
+
124
183
/**
125
184
* Perform inline edit request.
126
185
*
0 commit comments