From 5caedf7a6b298a4aaa1e949a0f83d252fa112fe3 Mon Sep 17 00:00:00 2001
From: Oleksandr Shmyheliuk <oshmyheliuk@magento.com>
Date: Fri, 6 Jan 2017 11:30:30 +0200
Subject: [PATCH] MAGETWO-62705: Implementation

---
 .../Command/App/SensitiveConfigSetCommand.php   |  2 +-
 .../App/SensitiveConfigSetCommandTest.php       |  3 +--
 .../Magento/Store/Model/Scope/Validator.php     | 17 ++++++++++-------
 .../Test/Unit/Model/Scope/ValidatorTest.php     | 12 ++++++------
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSetCommand.php b/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSetCommand.php
index 737284c2307..dee314c7259 100644
--- a/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSetCommand.php
+++ b/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSetCommand.php
@@ -145,7 +145,7 @@ class SensitiveConfigSetCommand extends Command
                 sprintf(
                     '<error>%s</error>',
                     'File app/etc/' . $configFilePath . ' can\'t be read. '
-                    . 'Please check if it exists and has correct permissions.'
+                    . 'Please check if it exists and has read permissions.'
                 )
             );
             return Cli::RETURN_FAILURE;
diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php
index bcf6cca667a..eb9cf3f4962 100644
--- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php
@@ -18,7 +18,6 @@ use Magento\Framework\Exception\FileSystemException;
 use Magento\Framework\Exception\LocalizedException;
 use Magento\Framework\Phrase;
 use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use Symfony\Component\Console\Question\QuestionFactory;
 use Symfony\Component\Console\Tester\CommandTester;
 
 class SensitiveConfigSetCommandTest extends \PHPUnit_Framework_TestCase
@@ -106,7 +105,7 @@ class SensitiveConfigSetCommandTest extends \PHPUnit_Framework_TestCase
         );
         $this->assertContains(
             'File app/etc/config.local.php can\'t be read. '
-            . 'Please check if it exists and has correct permissions.',
+            . 'Please check if it exists and has read permissions.',
             $tester->getDisplay()
         );
     }
diff --git a/app/code/Magento/Store/Model/Scope/Validator.php b/app/code/Magento/Store/Model/Scope/Validator.php
index ab09c42b01c..e0bb9289ba7 100644
--- a/app/code/Magento/Store/Model/Scope/Validator.php
+++ b/app/code/Magento/Store/Model/Scope/Validator.php
@@ -41,13 +41,13 @@ class Validator implements ValidatorInterface
 
         if ($scope === ScopeConfigInterface::SCOPE_TYPE_DEFAULT && !empty($scopeCode)) {
             throw new LocalizedException(__(
-                'Scope code shouldn\'t be passed for scope "%1"',
+                'The "%1" scope can’t include a scope code. Try again without entering a scope code.',
                 ScopeConfigInterface::SCOPE_TYPE_DEFAULT
             ));
         }
 
         if (empty($scope)) {
-            throw new LocalizedException(__('Scope can\'t be empty'));
+            throw new LocalizedException(__('Enter a scope before proceeding.'));
         }
 
         $this->validateScopeCode($scopeCode);
@@ -56,9 +56,9 @@ class Validator implements ValidatorInterface
             $scopeResolver = $this->scopeResolverPool->get($scope);
             $scopeResolver->getScope($scopeCode)->getId();
         } catch (InvalidArgumentException $e) {
-            throw new LocalizedException(__('Scope "%1" doesn\'t exist', $scope));
+            throw new LocalizedException(__('The "%1" value doesn’t exist. Enter another value.', $scope));
         } catch (NoSuchEntityException $e) {
-            throw new LocalizedException(__('Scope code "%1" doesn\'t exist in scope "%2"', $scopeCode, $scope));
+            throw new LocalizedException(__('The "%1" value doesn’t exist. Enter another value."', $scopeCode));
         }
 
         return true;
@@ -68,18 +68,21 @@ class Validator implements ValidatorInterface
      * Validate scope code
      * Throw exception if not valid.
      *
-     * @param $scopeCode
+     * @param string $scopeCode
      * @return void
      * @throws LocalizedException if scope code is empty or has a wrong format
      */
     private function validateScopeCode($scopeCode)
     {
         if (empty($scopeCode)) {
-            throw new LocalizedException(__('Scope code can\'t be empty'));
+            throw new LocalizedException(__('Enter a scope code before proceeding.'));
         }
 
         if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $scopeCode)) {
-            throw new LocalizedException(__('Wrong scope code format'));
+            throw new LocalizedException(__(
+                'The scope code can include only lowercase letters (a-z), numbers (0-9) and underscores (_). '
+                . 'Also, the first character must be a letter.'
+            ));
         }
     }
 }
diff --git a/app/code/Magento/Store/Test/Unit/Model/Scope/ValidatorTest.php b/app/code/Magento/Store/Test/Unit/Model/Scope/ValidatorTest.php
index 3081a99692a..c7a00eb2a40 100644
--- a/app/code/Magento/Store/Test/Unit/Model/Scope/ValidatorTest.php
+++ b/app/code/Magento/Store/Test/Unit/Model/Scope/ValidatorTest.php
@@ -64,7 +64,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage Scope code shouldn't be passed for scope "default"
+     * @expectedExceptionMessage The "default" scope can’t include a scope code. Try again without entering a scope code.
      */
     public function testNotEmptyScopeCodeForDefaultScope()
     {
@@ -73,7 +73,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage Scope can't be empty
+     * @expectedExceptionMessage Enter a scope before proceeding.
      */
     public function testEmptyScope()
     {
@@ -82,7 +82,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage Scope code can't be empty
+     * @expectedExceptionMessage Enter a scope code before proceeding.
      */
     public function testEmptyScopeCode()
     {
@@ -91,7 +91,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage Wrong scope code format
+     * @expectedExceptionMessage The scope code can include only lowercase letters (a-z), numbers (0-9) and underscores (_). Also, the first character must be a letter.
      */
     public function testWrongScopeCodeFormat()
     {
@@ -100,7 +100,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage Scope "not_default_scope" doesn't exist
+     * @expectedExceptionMessage The "not_default_scope" value doesn’t exist. Enter another value.
      */
     public function testScopeNotExist()
     {
@@ -115,7 +115,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage Scope code "not_exist_scope_code" doesn't exist in scope "not_default_scope"
+     * @expectedExceptionMessage The "not_exist_scope_code" value doesn’t exist. Enter another value.
      */
     public function testScopeCodeNotExist()
     {
-- 
GitLab