|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +use Magento\Customer\Api\AccountManagementInterface; |
| 9 | +use Magento\Customer\Api\CustomerMetadataInterface; |
| 10 | +use Magento\Customer\Api\Data\CustomerInterface; |
| 11 | +use Magento\Customer\Model\Data\CustomerFactory; |
| 12 | +use Magento\Customer\Model\GroupManagement; |
| 13 | +use Magento\Eav\Model\AttributeRepository; |
| 14 | +use Magento\TestFramework\Helper\Bootstrap; |
| 15 | + |
| 16 | +require __DIR__ . '/../../../Magento/Store/_files/second_website_with_two_stores.php'; |
| 17 | + |
| 18 | +$objectManager = Bootstrap::getObjectManager(); |
| 19 | +/** @var AccountManagementInterface $accountManagment */ |
| 20 | +$accountManagment = $objectManager->get(AccountManagementInterface::class); |
| 21 | +/** @var CustomerFactory $customerFactory */ |
| 22 | +$customerFactory = $objectManager->get(CustomerFactory::class); |
| 23 | +/** @var AttributeRepository $attributeRepository */ |
| 24 | +$attributeRepository = $objectManager->get(AttributeRepository::class); |
| 25 | +$gender = $attributeRepository->get(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, CustomerInterface::GENDER) |
| 26 | + ->getSource()->getOptionId('Male'); |
| 27 | +$defaultGroupId = $objectManager->get(GroupManagement::class)->getDefaultGroup($store->getStoreId())->getId(); |
| 28 | + |
| 29 | +$customer = $customerFactory->create(); |
| 30 | +$customer->setWebsiteId($websiteId) |
| 31 | + ->setEmail('customer@example.com') |
| 32 | + ->setGroupId($defaultGroupId) |
| 33 | + ->setStoreId($store->getStoreId()) |
| 34 | + ->setFirstname('John') |
| 35 | + ->setLastname('Smith') |
| 36 | + ->setDefaultBilling(1) |
| 37 | + ->setDefaultShipping(1) |
| 38 | + ->setGender($gender); |
| 39 | + |
| 40 | +$accountManagment->createAccount($customer, 'Apassword1'); |
0 commit comments