|
8 | 8 |
|
9 | 9 | use Magento\Customer\Api\AccountManagementInterface;
|
10 | 10 | use Magento\Customer\Api\CustomerRepositoryInterface;
|
11 |
| -use Magento\Customer\Api\Data\CustomerInterfaceFactory; |
| 11 | +use Magento\Customer\Api\Data\AddressInterface; |
12 | 12 | use Magento\Customer\Api\Data\AddressInterfaceFactory;
|
13 |
| -use Magento\Framework\Api\ExtensibleDataObjectConverter; |
14 |
| -use Magento\Framework\Api\DataObjectHelper; |
15 |
| -use Magento\Framework\Encryption\EncryptorInterface; |
16 | 13 | use Magento\Customer\Api\Data\CustomerInterface;
|
| 14 | +use Magento\Customer\Api\Data\CustomerInterfaceFactory; |
| 15 | +use Magento\Customer\Model\Customer; |
17 | 16 | use Magento\Customer\Model\CustomerRegistry;
|
| 17 | +use Magento\Framework\Api\DataObjectHelper; |
| 18 | +use Magento\Framework\Api\ExtensibleDataObjectConverter; |
| 19 | +use Magento\Framework\Api\FilterBuilder; |
| 20 | +use Magento\Framework\Api\SearchCriteriaBuilder; |
18 | 21 | use Magento\Framework\Api\SortOrder;
|
| 22 | +use Magento\Framework\Api\SortOrderBuilder; |
19 | 23 | use Magento\Framework\Config\CacheInterface;
|
| 24 | +use Magento\Framework\Encryption\EncryptorInterface; |
| 25 | +use Magento\Framework\Exception\NoSuchEntityException; |
20 | 26 | use Magento\Framework\ObjectManagerInterface;
|
21 | 27 | use Magento\Framework\Validator\Exception as ValidatorException;
|
22 | 28 | use Magento\Sales\Api\Data\OrderInterface;
|
23 | 29 | use Magento\Sales\Api\OrderRepositoryInterface;
|
24 | 30 | use Magento\TestFramework\Helper\Bootstrap;
|
25 |
| -use Magento\Customer\Api\Data\AddressInterface; |
26 |
| -use Magento\Framework\Api\SearchCriteriaBuilder; |
27 |
| -use Magento\Framework\Api\FilterBuilder; |
28 |
| -use Magento\Framework\Api\SortOrderBuilder; |
29 |
| -use Magento\Framework\Exception\NoSuchEntityException; |
30 |
| -use Magento\Customer\Model\Customer; |
| 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
|
@@ -244,6 +248,37 @@ public function testUpdateCustomer($defaultBilling, $defaultShipping)
|
244 | 248 | $this->assertNotContains('password_hash', array_keys($inAfterOnly));
|
245 | 249 | }
|
246 | 250 |
|
| 251 | + /** |
| 252 | + * Test update customer custom attributes |
| 253 | + * |
| 254 | + * @magentoDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php |
| 255 | + * @return void |
| 256 | + */ |
| 257 | + #[ |
| 258 | + DataFixture(\Magento\Customer\Test\Fixture\Customer::class, ['email' => 'customer@mail.com']) |
| 259 | + ] |
| 260 | + |
| 261 | + public function testUpdateCustomerAttributesAutoIncrement() |
| 262 | + { |
| 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'); |
| 271 | + |
| 272 | + $this->assertSame( |
| 273 | + $customer->getCustomAttribute('custom_attribute1')->getValue(), |
| 274 | + $updateAttributeValue |
| 275 | + ); |
| 276 | + $resource = $this->objectManager->get(\Magento\Framework\App\ResourceConnection::class); |
| 277 | + $connection = $resource->getConnection(); |
| 278 | + $tableStatus = $connection->showTableStatus('customer_entity_varchar'); |
| 279 | + $this->assertSame($tableStatus['Auto_increment'], '2'); |
| 280 | + } |
| 281 | + |
247 | 282 | /**
|
248 | 283 | * Test update customer address
|
249 | 284 | *
|
|
0 commit comments