Skip to content

Commit e7fa37a

Browse files
committed
ACP2E-1358, added integration test
1 parent 03ed31e commit e7fa37a

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88

99
use Magento\Customer\Api\AccountManagementInterface;
1010
use Magento\Customer\Api\CustomerRepositoryInterface;
11-
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
11+
use Magento\Customer\Api\Data\AddressInterface;
1212
use Magento\Customer\Api\Data\AddressInterfaceFactory;
13-
use Magento\Framework\Api\ExtensibleDataObjectConverter;
14-
use Magento\Framework\Api\DataObjectHelper;
15-
use Magento\Framework\Encryption\EncryptorInterface;
1613
use Magento\Customer\Api\Data\CustomerInterface;
14+
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
15+
use Magento\Customer\Model\Customer;
1716
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;
1821
use Magento\Framework\Api\SortOrder;
22+
use Magento\Framework\Api\SortOrderBuilder;
1923
use Magento\Framework\Config\CacheInterface;
24+
use Magento\Framework\Encryption\EncryptorInterface;
25+
use Magento\Framework\Exception\NoSuchEntityException;
2026
use Magento\Framework\ObjectManagerInterface;
2127
use Magento\Framework\Validator\Exception as ValidatorException;
2228
use Magento\Sales\Api\Data\OrderInterface;
2329
use Magento\Sales\Api\OrderRepositoryInterface;
2430
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;
3131

3232
/**
3333
* Checks Customer insert, update, search with repository
@@ -244,6 +244,53 @@ public function testUpdateCustomer($defaultBilling, $defaultShipping)
244244
$this->assertNotContains('password_hash', array_keys($inAfterOnly));
245245
}
246246

247+
/**
248+
* Test update customer custom attributes
249+
*
250+
* @magentoDbIsolation enabled
251+
* @magentoDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php
252+
* @return void
253+
*/
254+
public function testUpdateCustomerAttributesAutoIncrement()
255+
{
256+
$email = 'email@example.com';
257+
$storeId = 1;
258+
$firstname = 'Tester';
259+
$lastname = 'McTest';
260+
$groupId = 1;
261+
$newAttributeValue = 'test1';
262+
$updateAttributeValue = 'test2';
263+
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+
$this->assertSame(
284+
$customerAfter->getCustomAttribute('custom_attribute1')->getValue(),
285+
$updateAttributeValue
286+
);
287+
288+
$resource = $this->objectManager->get(\Magento\Framework\App\ResourceConnection::class);
289+
$connection = $resource->getConnection();
290+
$tableStatus = $connection->showTableStatus('customer_entity_varchar');
291+
$this->assertSame($tableStatus['Auto_increment'], '2');
292+
}
293+
247294
/**
248295
* Test update customer address
249296
*

0 commit comments

Comments
 (0)