create(\Magento\Customer\Model\Customer::class); /** @var CustomerRegistry $customerRegistry */ $customerRegistry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(CustomerRegistry::class); $customerData = [ 'group_id' => 1, 'website_id' => 1, 'store_id' => 1, 'firstname' => 'test firstname', 'lastname' => 'test lastname', 'email' => 'customer@example.com', 'default_billing' => 1, 'default_shipping' => 1, 'password' => '123123q', 'attribute_set_id' => 1, ]; $customer->setData($customerData); $customer->setId(1); /** @var \Magento\Customer\Model\Address $addressOne */ $addressOne = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Customer\Model\Address::class ); $addressOneData = [ 'firstname' => 'test firstname', 'lastname' => 'test lastname', 'street' => ['test street'], 'city' => 'test city', 'region_id' => 10, 'country_id' => 'US', 'postcode' => '01001', 'telephone' => '+7000000001', 'entity_id' => 1, ]; $addressOne->setData($addressOneData); $customer->addAddress($addressOne); /** @var \Magento\Customer\Model\Address $addressTwo */ $addressTwo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Customer\Model\Address::class ); $addressTwoData = [ 'firstname' => 'test firstname', 'lastname' => 'test lastname', 'street' => ['test street'], 'city' => 'test city', 'region_id' => 10, 'country_id' => 'US', 'postcode' => '01001', 'telephone' => '+7000000001', 'entity_id' => 2, ]; $addressTwo->setData($addressTwoData); $customer->addAddress($addressTwo); /** @var \Magento\Customer\Model\Address $addressThree */ $addressThree = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Customer\Model\Address::class ); $addressThreeData = [ 'firstname' => 'removed firstname', 'lastname' => 'removed lastname', 'street' => ['removed street'], 'city' => 'removed city', 'region_id' => 10, 'country_id' => 'US', 'postcode' => '01001', 'telephone' => '+7000000001', 'entity_id' => 3, ]; $addressThree->setData($addressThreeData); $customer->addAddress($addressThree); $customer->save(); $customerRegistry->remove($customer->getId());