/**
  * 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]);
 }
 /**
  * Assert customer availability in Customer Grid
  *
  * @param Customer $customer
  * @param CustomerIndex $pageCustomerIndex
  * @param Customer $initialCustomer [optional]
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, Customer $initialCustomer = null)
 {
     if ($initialCustomer) {
         $customer = $customer->hasData() ? array_merge($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData();
     } else {
         $customer = $customer->getData();
     }
     $name = (isset($customer['prefix']) ? $customer['prefix'] . ' ' : '') . $customer['firstname'] . (isset($customer['middlename']) ? ' ' . $customer['middlename'] : '') . ' ' . $customer['lastname'] . (isset($customer['suffix']) ? ' ' . $customer['suffix'] : '');
     $filter = ['name' => $name, 'email' => $customer['email']];
     $pageCustomerIndex->open();
     \PHPUnit_Framework_Assert::assertTrue($pageCustomerIndex->getCustomerGridBlock()->isRowVisible($filter), 'Customer with ' . 'name \'' . $filter['name'] . '\', ' . 'email \'' . $filter['email'] . '\' ' . 'is absent in Customer grid.');
 }
 /**
  * Prepares customer returned after test.
  *
  * @param Customer $customer
  * @param Customer $initialCustomer
  * @param Address|null $address
  * @param Address|null $addressToDelete
  * @return Customer
  */
 private function prepareCustomer(Customer $customer, Customer $initialCustomer, Address $address = null, Address $addressToDelete = null)
 {
     $data = $customer->hasData() ? array_replace_recursive($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData();
     $groupId = $customer->hasData('group_id') ? $customer : $initialCustomer;
     $data['group_id'] = ['customerGroup' => $groupId->getDataFieldConfig('group_id')['source']->getCustomerGroup()];
     if ($initialCustomer->hasData('address')) {
         $addressesList = $initialCustomer->getDataFieldConfig('address')['source']->getAddresses();
         foreach ($addressesList as $key => $addressFixture) {
             if ($addressToDelete === null || $addressFixture != $address) {
                 $data['address'] = ['addresses' => [$key => $addressFixture]];
             }
         }
     }
     if ($address !== null) {
         $data['address']['addresses'][] = $address;
     }
     return $this->fixtureFactory->createByCode('customer', ['data' => $data]);
 }
示例#4
0
 /**
  * Prepare customer data for Web API.
  *
  * @param Customer $customer
  * @return array
  */
 protected function prepareData(Customer $customer)
 {
     $data['customer'] = $this->replaceMappingData($customer->getData());
     $data['customer']['group_id'] = $this->getCustomerGroup($customer);
     $data['password'] = $data['customer']['password'];
     unset($data['customer']['password']);
     unset($data['customer']['password_confirmation']);
     $data = $this->prepareAddressData($data);
     return $data;
 }
 /**
  * Get all error validation messages for fields.
  *
  * @param Customer $customer
  * @return array
  */
 public function getValidationMessages(Customer $customer)
 {
     $messages = [];
     foreach (array_keys($customer->getData()) as $field) {
         $element = $this->_rootElement->find(sprintf($this->validationText, str_replace('_', '-', $field)));
         if ($element->isVisible()) {
             $messages[$field] = $element->getText();
         }
     }
     return $messages;
 }
 /**
  * Assert that displayed customer data on edit page(backend) equals passed from fixture
  *
  * @param Customer $customer
  * @param CustomerIndex $pageCustomerIndex
  * @param CustomerIndexEdit $pageCustomerIndexEdit
  * @param Address $address[optional]
  * @param Customer $initialCustomer [optional]
  * @return void
  */
 public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, CustomerIndexEdit $pageCustomerIndexEdit, Address $address = null, Customer $initialCustomer = null)
 {
     $data = [];
     $filter = [];
     if ($initialCustomer) {
         $data['customer'] = $customer->hasData() ? array_merge($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData();
     } else {
         $data['customer'] = $customer->getData();
     }
     if ($address) {
         $data['addresses'][1] = $address->hasData() ? $address->getData() : [];
     } else {
         $data['addresses'] = [];
     }
     $filter['email'] = $data['customer']['email'];
     $pageCustomerIndex->open();
     $pageCustomerIndex->getCustomerGridBlock()->searchAndOpen($filter);
     $dataForm = $pageCustomerIndexEdit->getCustomerForm()->getDataCustomer($customer, $address);
     $dataDiff = $this->verify($data, $dataForm);
     \PHPUnit_Framework_Assert::assertTrue(empty($dataDiff), 'Customer data on edit page(backend) not equals to passed from fixture.' . "\nFailed values: " . implode(', ', $dataDiff));
 }
示例#7
0
 /**
  * Prepare customer data.
  *
  * @param array $data
  * @return array
  */
 protected function prepareCustomerData(array $data)
 {
     return ['currency_id' => $data['base_currency_code'], 'customer_id' => $this->customer->getData('id'), 'payment' => $data['payment_authorization_amount'], 'store_id' => $this->order->getDataFieldConfig('store_id')['source']->store->getStoreId()];
 }
 /**
  * Save new customer and get form key
  *
  * @param \Magento\Customer\Test\Fixture\Customer $fixture
  * @return CurlTransport
  */
 protected function saveCustomer(\Magento\Customer\Test\Fixture\Customer $fixture)
 {
     $data = $fixture->getData('fields');
     $fields = array();
     foreach ($data as $key => $field) {
         $fields[$key] = $field['value'];
     }
     $url = $_ENV['app_frontend_url'] . $this->saveCustomer;
     $curl = new CurlTransport();
     $curl->write(CurlInterface::POST, $url, '1.0', array(), $fields);
     $curl->read();
     $urlForm = $_ENV['app_frontend_url'] . $this->addressNew;
     $curl->write(CurlInterface::GET, $urlForm, '1.0', array());
     $response = $curl->read();
     $this->formKey = $this->getFromKey($response);
     return $curl;
 }
 /**
  * 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]);
 }