|
28 | 28 | use Magento\Sales\Api\Data\OrderInterface;
|
29 | 29 | use Magento\Sales\Api\OrderRepositoryInterface;
|
30 | 30 | use Magento\TestFramework\Helper\Bootstrap;
|
| 31 | +use Magento\TestFramework\Fixture\Config as ConfigFixture; |
| 32 | +use Magento\TestFramework\Fixture\DataFixture; |
| 33 | +use Magento\TestFramework\Fixture\DataFixtureStorage; |
| 34 | +use Magento\TestFramework\Fixture\DataFixtureStorageManager; |
31 | 35 |
|
32 | 36 | /**
|
33 | 37 | * Checks Customer insert, update, search with repository
|
@@ -247,44 +251,28 @@ public function testUpdateCustomer($defaultBilling, $defaultShipping)
|
247 | 251 | /**
|
248 | 252 | * Test update customer custom attributes
|
249 | 253 | *
|
250 |
| - * @magentoDbIsolation enabled |
251 | 254 | * @magentoDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php
|
252 | 255 | * @return void
|
253 | 256 | */
|
| 257 | + #[ |
| 258 | + DataFixture(\Magento\Customer\Test\Fixture\Customer::class, ['email' => 'customer@mail.com']) |
| 259 | + ] |
| 260 | + |
254 | 261 | public function testUpdateCustomerAttributesAutoIncrement()
|
255 | 262 | {
|
256 |
| - $email = 'email@example.com'; |
257 |
| - $storeId = 1; |
258 |
| - $firstname = 'Tester'; |
259 |
| - $lastname = 'McTest'; |
260 |
| - $groupId = 1; |
261 |
| - $newAttributeValue = 'test1'; |
262 |
| - $updateAttributeValue = 'test2'; |
| 263 | + $newAttributeValue = 'value1'; |
| 264 | + $updateAttributeValue = 'value2'; |
| 265 | + $customer = $this->customerRepository->get('customer@mail.com'); |
| 266 | + $customer->setCustomAttribute('custom_attribute1', $newAttributeValue); |
| 267 | + $savedCustomer = $this->customerRepository->save($customer); |
| 268 | + $savedCustomer->setCustomAttribute('custom_attribute1', $updateAttributeValue); |
| 269 | + $this->customerRepository->save($savedCustomer); |
| 270 | + $customer = $this->customerRepository->get('customer@mail.com'); |
263 | 271 |
|
264 |
| - $newCustomerEntity = $this->customerFactory->create() |
265 |
| - ->setStoreId($storeId) |
266 |
| - ->setEmail($email) |
267 |
| - ->setFirstname($firstname) |
268 |
| - ->setLastname($lastname) |
269 |
| - ->setGroupId($groupId); |
270 |
| - $newCustomerEntity->setCustomAttribute('custom_attribute1', $newAttributeValue); |
271 |
| - $savedCustomer = $this->customerRepository->save($newCustomerEntity); |
272 |
| - |
273 |
| - $updatedCustomer = $this->customerFactory->create(); |
274 |
| - $this->dataObjectHelper->mergeDataObjects( |
275 |
| - CustomerInterface::class, |
276 |
| - $updatedCustomer, |
277 |
| - $savedCustomer |
278 |
| - ); |
279 |
| - $updatedCustomer->setCustomAttribute('custom_attribute1', $updateAttributeValue); |
280 |
| - $this->customerRepository->save($updatedCustomer); |
281 |
| - |
282 |
| - $customerAfter = $this->customerRepository->getById($savedCustomer->getId()); |
283 | 272 | $this->assertSame(
|
284 |
| - $customerAfter->getCustomAttribute('custom_attribute1')->getValue(), |
| 273 | + $customer->getCustomAttribute('custom_attribute1')->getValue(), |
285 | 274 | $updateAttributeValue
|
286 | 275 | );
|
287 |
| - |
288 | 276 | $resource = $this->objectManager->get(\Magento\Framework\App\ResourceConnection::class);
|
289 | 277 | $connection = $resource->getConnection();
|
290 | 278 | $tableStatus = $connection->showTableStatus('customer_entity_varchar');
|
|
0 commit comments