From 1948afe99337440defe4a24f4f21b763fc5dd78a Mon Sep 17 00:00:00 2001
From: Max Lesechko <mlesechko@magento.com>
Date: Thu, 22 Dec 2016 18:20:29 +0200
Subject: [PATCH] MAGETWO-60002: Update functional test handler to avoid code
 duplication

---
 .../Handler/CatalogProductAttribute/Curl.php  | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php
index db43cc535ca..ddf036fd18a 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php
@@ -17,6 +17,20 @@ use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator;
  */
 class Curl extends AbstractCurl implements CatalogProductAttributeInterface
 {
+    /**
+     * Relative action path with parameters.
+     *
+     * @var string
+     */
+    protected $urlActionPath = 'catalog/product_attribute/save/back/edit';
+
+    /**
+     * Message for Exception when was received not successful response.
+     *
+     * @var string
+     */
+    protected $responseExceptionMessage = 'Product Attribute creating by curl handler was not successful!';
+
     /**
      * Mapping values for data.
      *
@@ -85,14 +99,15 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface
         }
 
         $data = $this->changeStructureOfTheData($data);
-        $url = $_ENV['app_backend_url'] . 'catalog/product_attribute/save/back/edit';
+        $url = $_ENV['app_backend_url'] . $this->urlActionPath;
         $curl = new BackendDecorator(new CurlTransport(), $this->_configuration);
         $curl->write($url, $data);
         $response = $curl->read();
         $curl->close();
 
         if (!strpos($response, 'data-ui-id="messages-message-success"')) {
-            throw new \Exception("Product Attribute creating by curl handler was not successful! \n" . $response);
+            $this->_eventManager->dispatchEvent(['curl_failed'], [$response]);
+            throw new \Exception($this->responseExceptionMessage);
         }
 
         $resultData = [];
-- 
GitLab