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 CustomerInjectable $customer */
     $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
     $data = $customer->getData();
     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();
     if (!strpos($response, 'data-ui-id="global-messages-message-success"')) {
         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->addAddress($data);
     }
     return $result;
 }
Example #2
0
 /**
  * Post request for creating customer
  *
  * @param FixtureInterface $fixture [optional]
  * @return mixed|string
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $data = $fixture->getData('fields');
     $fields = array();
     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', array(), $fields);
     $response = $curl->read();
     $curl->close();
     return $response;
 }
Example #3
0
 /**
  * Post request for creating customer in frontend
  *
  * @param FixtureInterface|null $customer
  * @return array
  * @throws \Exception
  */
 public function persist(FixtureInterface $customer = null)
 {
     /** @var CustomerInjectable $customer */
     $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
     $data = $customer->getData();
     $curl = new CurlTransport();
     $curl->write(CurlInterface::POST, $url, '1.0', array(), $data);
     $response = $curl->read();
     $curl->close();
     if (!strpos($response, 'data-ui-id="global-messages-message-success"')) {
         throw new \Exception("Customer entity creating  by curl handler was not successful! Response: {$response}");
     }
     return ['id' => $this->getCustomerId($customer->getEmail())];
 }
Example #4
0
 /**
  * Connect to Jira for getting information about ticket
  *
  * @param string $jiraTicket
  *
  * @return array
  * @throws \Exception
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function getTicketData($jiraTicket)
 {
     if (!isset($jiraTicket['id'])) {
         throw new \Exception('Test case item #' . $this->cnt . ' does not have ticket id.');
     }
     $ticketId = $jiraTicket['id'];
     $credentials = $this->config['username'] . ':' . $this->config['password'];
     $url = $this->config['url'] . 'issue/' . $ticketId;
     $curl = new CurlTransport();
     $curl->setOptions([CURLOPT_SSL_VERIFYPEER => false, CURLOPT_USERPWD => $credentials]);
     $curl->write(CurlInterface::GET, $url, '1.0');
     $response = $curl->read();
     $curl->close();
     $issue = json_decode($response, true);
     if ($issue === null) {
         throw new \Exception('Connection to Jira has been failed, verify jira config file settings.');
     }
     $ticketData = [];
     $ticketData['ticketId'] = $jiraTicket['id'];
     // Get ticket name
     $stringRemove = ['Cover ', 'Test Creation for ', 'with functional test designed for automation'];
     $ticketData['name'] = str_replace(' ', '', ucwords(str_replace($stringRemove, '', $issue['fields']['summary']))) . 'Test';
     $ticketData['description'] = $issue['fields']['summary'];
     // Get 'Magento Module' value
     $ticketData['module'] = isset($issue['fields']['customfield_13222']['value']) ? $issue['fields']['customfield_13222']['value'] : null;
     // Get ticket components
     if (isset($issue['fields']['components'])) {
         foreach ($issue['fields']['components'] as $component) {
             $ticketData['components'][] = $component['name'];
         }
     }
     // Get test case steps form ticket description
     $stepsDelimiter = "*Test Flow:*\r\n";
     preg_match('/' . preg_quote($stepsDelimiter) . '((\\s)*\\S)*/', $issue['fields']['description'], $matches);
     $ticketData['steps'] = empty($matches) ? [] : explode("\r\n", str_replace([$stepsDelimiter, '#'], '', $matches[0]));
     return $ticketData;
 }
 /**
  * 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;
 }
Example #6
0
 /**
  * Close the connection to the server
  *
  * @return void
  */
 public function close()
 {
     $this->transport->close();
 }