Skip to content

Commit 4af293f

Browse files
author
Yevhen Miroshnychenko
committed
Merge remote-tracking branch 'falconsce/MAGETWO-63764' into MAGETWO-64335
2 parents cd37f24 + a41493e commit 4af293f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

lib/internal/Magento/Framework/App/Scope/Validator.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use InvalidArgumentException;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
1010
use Magento\Framework\App\ScopeResolverPool;
11-
use Magento\Framework\Exception\LocalizedException;
1211
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Framework\Exception\ValidatorException;
1313
use Magento\Framework\Phrase;
1414

1515
/**
@@ -40,14 +40,14 @@ public function isValid($scope, $scopeCode = null)
4040
}
4141

4242
if ($scope === ScopeConfigInterface::SCOPE_TYPE_DEFAULT && !empty($scopeCode)) {
43-
throw new LocalizedException(new Phrase(
43+
throw new ValidatorException(new Phrase(
4444
'The "%1" scope can\'t include a scope code. Try again without entering a scope code.',
4545
[ScopeConfigInterface::SCOPE_TYPE_DEFAULT]
4646
));
4747
}
4848

4949
if (empty($scope)) {
50-
throw new LocalizedException(new Phrase('Enter a scope before proceeding.'));
50+
throw new ValidatorException(new Phrase('Enter a scope before proceeding.'));
5151
}
5252

5353
$this->validateScopeCode($scopeCode);
@@ -56,9 +56,9 @@ public function isValid($scope, $scopeCode = null)
5656
$scopeResolver = $this->scopeResolverPool->get($scope);
5757
$scopeResolver->getScope($scopeCode)->getId();
5858
} catch (InvalidArgumentException $e) {
59-
throw new LocalizedException(new Phrase('The "%1" value doesn\'t exist. Enter another value.', [$scope]));
59+
throw new ValidatorException(new Phrase('The "%1" value doesn\'t exist. Enter another value.', [$scope]));
6060
} catch (NoSuchEntityException $e) {
61-
throw new LocalizedException(
61+
throw new ValidatorException(
6262
new Phrase('The "%1" value doesn\'t exist. Enter another value.', [$scopeCode])
6363
);
6464
}
@@ -72,16 +72,16 @@ public function isValid($scope, $scopeCode = null)
7272
*
7373
* @param string $scopeCode
7474
* @return void
75-
* @throws LocalizedException if scope code is empty or has a wrong format
75+
* @throws ValidatorException if scope code is empty or has a wrong format
7676
*/
7777
private function validateScopeCode($scopeCode)
7878
{
7979
if (empty($scopeCode)) {
80-
throw new LocalizedException(new Phrase('Enter a scope code before proceeding.'));
80+
throw new ValidatorException(new Phrase('Enter a scope code before proceeding.'));
8181
}
8282

8383
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $scopeCode)) {
84-
throw new LocalizedException(new Phrase(
84+
throw new ValidatorException(new Phrase(
8585
'The scope code can include only lowercase letters (a-z), numbers (0-9) and underscores (_). '
8686
. 'Also, the first character must be a letter.'
8787
));

lib/internal/Magento/Framework/App/Scope/ValidatorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
namespace Magento\Framework\App\Scope;
77

8-
use Magento\Framework\Exception\LocalizedException;
8+
use Magento\Framework\Exception\ValidatorException;
99

1010
/**
1111
* Interface Validator for validating scope and scope code
@@ -19,7 +19,7 @@ interface ValidatorInterface
1919
* @param string $scope
2020
* @param string $scopeCode
2121
* @return boolean
22-
* @throws LocalizedException
22+
* @throws ValidatorException
2323
*/
2424
public function isValid($scope, $scopeCode = null);
2525
}

lib/internal/Magento/Framework/App/Test/Unit/Config/Scope/ValidatorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testIsValidDefault()
6666
}
6767

6868
/**
69-
* @expectedException \Magento\Framework\Exception\LocalizedException
69+
* @expectedException \Magento\Framework\Exception\ValidatorException
7070
* @expectedExceptionMessage The "default" scope can't include a scope code. Try again without entering a scope
7171
*/
7272
public function testNotEmptyScopeCodeForDefaultScope()
@@ -75,7 +75,7 @@ public function testNotEmptyScopeCodeForDefaultScope()
7575
}
7676

7777
/**
78-
* @expectedException \Magento\Framework\Exception\LocalizedException
78+
* @expectedException \Magento\Framework\Exception\ValidatorException
7979
* @expectedExceptionMessage Enter a scope before proceeding.
8080
*/
8181
public function testEmptyScope()
@@ -84,7 +84,7 @@ public function testEmptyScope()
8484
}
8585

8686
/**
87-
* @expectedException \Magento\Framework\Exception\LocalizedException
87+
* @expectedException \Magento\Framework\Exception\ValidatorException
8888
* @expectedExceptionMessage Enter a scope code before proceeding.
8989
*/
9090
public function testEmptyScopeCode()
@@ -93,7 +93,7 @@ public function testEmptyScopeCode()
9393
}
9494

9595
/**
96-
* @expectedException \Magento\Framework\Exception\LocalizedException
96+
* @expectedException \Magento\Framework\Exception\ValidatorException
9797
* @expectedExceptionMessage The scope code can include only lowercase letters (a-z), numbers (0-9) and underscores
9898
*/
9999
public function testWrongScopeCodeFormat()
@@ -102,7 +102,7 @@ public function testWrongScopeCodeFormat()
102102
}
103103

104104
/**
105-
* @expectedException \Magento\Framework\Exception\LocalizedException
105+
* @expectedException \Magento\Framework\Exception\ValidatorException
106106
* @expectedExceptionMessage The "not_default_scope" value doesn't exist. Enter another value.
107107
*/
108108
public function testScopeNotExist()
@@ -117,7 +117,7 @@ public function testScopeNotExist()
117117
}
118118

119119
/**
120-
* @expectedException \Magento\Framework\Exception\LocalizedException
120+
* @expectedException \Magento\Framework\Exception\ValidatorException
121121
* @expectedExceptionMessage The "not_exist_scope_code" value doesn't exist. Enter another value.
122122
*/
123123
public function testScopeCodeNotExist()

0 commit comments

Comments
 (0)