Example #1
0
 /**
  * Post request for creating customer in frontend
  *
  * @param FixtureInterface|null $customer
  * @return array
  * @throws \Exception
  */
 public function persist(FixtureInterface $customer = null)
 {
     $address = [];
     $result = [];
     /** @var Customer $customer */
     $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
     $data = $customer->getData();
     $data['group_id'] = $this->getCustomerGroup($customer);
     if ($customer->hasData('address')) {
         $address = $customer->getAddress();
         unset($data['address']);
     }
     $curl = new CurlTransport();
     $curl->write(CurlInterface::POST, $url, '1.0', [], $data);
     $response = $curl->read();
     $curl->close();
     // After caching My Account page we cannot check by success message
     if (!strpos($response, 'customer/account/logout')) {
         throw new \Exception("Customer entity creating  by curl handler was not successful! Response: {$response}");
     }
     $result['id'] = $this->getCustomerId($customer->getEmail());
     $data['customer_id'] = $result['id'];
     if (!empty($address)) {
         $data['address'] = $address;
     }
     $this->updateCustomer($data);
     return $result;
 }
Example #2
0
 /**
  * Post request for creating customer in frontend.
  *
  * @param FixtureInterface|null $customer
  * @return array
  * @throws \Exception
  */
 public function persist(FixtureInterface $customer = null)
 {
     $result = [];
     /** @var Customer $customer */
     $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
     $data = $customer->getData();
     $data['group_id'] = $this->getCustomerGroup($customer);
     if ($customer->hasData('address')) {
         $data['address'] = http_build_query($data['address']);
     }
     $curl = new CurlTransport();
     $curl->write(CurlInterface::POST, $url, '1.0', [], $data);
     $response = $curl->read();
     $curl->close();
     if (!strpos($response, 'class="success-msg"')) {
         throw new \Exception("Customer entity creating by curl handler was not successful! Response: {$response}");
     }
     $result['id'] = $this->getCustomerId($customer->getEmail());
     $data['customer_id'] = $result['id'];
     if ($this->checkForUpdateData($data)) {
         parse_str($data['address'], $data['address']);
         $this->updateCustomer($data);
     }
     return $result;
 }
 /**
  * Read response from server.
  *
  * @return string
  */
 public function read()
 {
     $this->response = $this->transport->read();
     $this->initCookies();
     $this->initFormKey();
     return $this->response;
 }
 /**
  * Post request for creating customer
  *
  * @param FixtureInterface $fixture [optional]
  * @return mixed|string
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $data = $fixture->getData('fields');
     $fields = [];
     foreach ($data as $key => $field) {
         $fields[$key] = $field['value'];
     }
     $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
     $curl = new CurlTransport();
     $curl->write(CurlInterface::POST, $url, '1.0', [], $fields);
     $response = $curl->read();
     $curl->close();
     return $response;
 }
Example #5
0
 /**
  * Read response from server.
  *
  * @return string
  */
 public function read()
 {
     $this->response = $this->transport->read();
     return $this->response;
 }
 /**
  * Read response from server.
  *
  * @return string
  */
 public function read()
 {
     $this->_response = $this->_transport->read();
     $this->_initFormKey();
     return $this->_response;
 }
Example #7
0
 /**
  * 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 = [];
     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', [], $fields);
     $curl->read();
     $urlForm = $_ENV['app_frontend_url'] . $this->addressNew;
     $curl->write(CurlInterface::GET, $urlForm, '1.0', []);
     $response = $curl->read();
     $this->formKey = $this->getFromKey($response);
     return $curl;
 }