/**
  * Prepare VAT ID confguration.
  *
  * @param ConfigData $vatConfig
  * @param string $customerGroup
  * @return void
  */
 protected function prepareVatConfig(ConfigData $vatConfig, $customerGroup)
 {
     $groupConfig = ['customer/create_account/viv_domestic_group' => ['value' => $this->vatGroups['valid_domestic_group']->getCustomerGroupId()], 'customer/create_account/viv_intra_union_group' => ['value' => $this->vatGroups['valid_intra_union_group']->getCustomerGroupId()], 'customer/create_account/viv_invalid_group' => ['value' => $this->vatGroups['invalid_group']->getCustomerGroupId()], 'customer/create_account/viv_error_group' => ['value' => $this->vatGroups['error_group']->getCustomerGroupId()]];
     $vatConfig = $this->fixtureFactory->createByCode('configData', ['data' => array_replace_recursive($vatConfig->getSection(), $groupConfig)]);
     $vatConfig->persist();
     $customerData = array_merge($this->customer->getData(), ['group_id' => ['value' => $this->vatGroups[$customerGroup]->getCustomerGroupCode()]], ['address' => ['addresses' => $this->customer->getDataFieldConfig('address')['source']->getAddresses()]]);
     $this->customer = $this->fixtureFactory->createByCode('customer', ['data' => $customerData]);
 }
 /**
  * Fill customer addresses and proceed to next step.
  *
  * @return void
  */
 public function run()
 {
     $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses();
     $bindings = [];
     foreach ($this->products as $key => $product) {
         $productName = $product->getName();
         $addressRender = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addresses[$key], 'type' => 'oneline']);
         $bindings[$productName] = $addressRender->render();
     }
     $this->addresses->getAddressesBlock()->selectAddresses($bindings);
 }
 /**
  * Create customer with customer group and apply customer group to catalog price rule.
  *
  * @param CatalogRule $catalogPriceRule
  * @param Customer|null $customer
  * @return CustomerGroup
  */
 public function applyCustomerGroup(CatalogRule $catalogPriceRule, Customer $customer = null)
 {
     if ($customer !== null) {
         $customer->persist();
         /** @var \Magento\Customer\Test\Fixture\CustomerGroup $customerGroup */
         $customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup();
         $catalogPriceRule = $this->fixtureFactory->createByCode('catalogRule', ['data' => array_merge($catalogPriceRule->getData(), ['customer_group_ids' => $customerGroup->getCustomerGroupCode()])]);
     }
     return $catalogPriceRule;
 }
 /**
  * Runs Delete Customer Address test.
  *
  * @param Customer $customer
  * @return array
  */
 public function test(Customer $customer)
 {
     // Precondition:
     $customer->persist();
     $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1];
     // Steps:
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete);
     return ['deletedAddress' => $addressToDelete];
 }
 /**
  * Runs Delete Customer Address test.
  *
  * @param Customer $customer
  * @return array
  */
 public function test(Customer $customer)
 {
     $this->markTestIncomplete('Bug: MAGETWO-34634');
     // Precondition:
     $customer->persist();
     $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1];
     // Steps:
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink("Log In");
     $this->customerAccountLogin->getLoginBlock()->login($customer);
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete);
     return ['deletedAddress' => $addressToDelete];
 }
 /**
  * Delete Customer Group.
  *
  * @param CustomerGroup $customerGroup
  * @param Customer $customer [optional]
  * @return array
  */
 public function test(CustomerGroup $customerGroup, Customer $customer = null)
 {
     // Precondition
     if ($customer !== null) {
         $customer->persist();
         $customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup();
     } else {
         $customerGroup->persist();
     }
     // Steps
     $filter = ['code' => $customerGroup->getCustomerGroupCode()];
     $this->customerGroupIndex->open();
     $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
     $this->customerGroupNew->getPageMainActions()->delete();
     $this->customerGroupNew->getModalBlock()->acceptAlert();
     return ['customer' => $customer, 'customerGroup' => $customerGroup];
 }
예제 #7
0
 /**
  * Prepare order data.
  *
  * @param array $data
  * @return array
  */
 protected function prepareOrderData(array $data)
 {
     $customerGroupId = $this->customer->hasData('group_id') ? $this->customer->getDataFieldConfig('group_id')['source']->getCustomerGroup()->getCustomerGroupId() : 1;
     $result = ['name' => $this->customer->getFirstname(), 'order' => ['currency' => $data['order_currency_code'], 'account' => ['group_id' => $customerGroupId, 'email' => $this->customer->getEmail()], 'shipping_method' => isset($data['shipping_method']) ? $data['shipping_method'] : ''], 'item' => $this->prepareOrderProductsData($data['entity_id']), 'billing_address' => $this->prepareBillingAddress($data['billing_address_id']), 'shipping_same_as_billing' => 'on', 'payment' => $data['payment_auth_expiration']];
     return $result;
 }
 /**
  * Run update customer test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address|null $address
  * @param int|null $addressIndexToDelete
  * @throws \Exception
  * @return array
  */
 public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null, $addressIndexToDelete = null)
 {
     // Precondition
     $initialCustomer->persist();
     $addressToDelete = null;
     if ($addressIndexToDelete !== null) {
         $addressToDelete = $initialCustomer->getDataFieldConfig('address')['source']->getAddresses()[$addressIndexToDelete];
     }
     // Steps
     $filter = ['email' => $initialCustomer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address, $addressToDelete);
     $this->customerIndexEditPage->getPageActionsBlock()->save();
     return ['customer' => $this->prepareCustomer($customer, $initialCustomer, $address, $addressToDelete), 'addressToDelete' => $addressToDelete];
 }
예제 #9
0
 /**
  * Get customer group.
  *
  * @param Customer $customer
  * @return string
  */
 protected function getCustomerGroup(Customer $customer)
 {
     return $customer->hasData('group_id') ? $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup()->getCustomerGroupId() : self::GENERAL_GROUP;
 }
 /**
  * Prepares customer returned after test.
  *
  * @param Customer $customer
  * @param Customer $initialCustomer
  * @return Customer
  */
 private function prepareCustomer(Customer $customer, Customer $initialCustomer)
 {
     if (!$customer->hasData()) {
         return $initialCustomer;
     }
     $data = array_replace_recursive($initialCustomer->getData(), $customer->getData());
     $data['group_id'] = ['customerGroup' => $initialCustomer->getDataFieldConfig('group_id')['source']->getCustomerGroup()];
     return $this->fixtureFactory->createByCode('customer', ['data' => $data]);
 }