Skip to content

Commit 8046ec9

Browse files
author
Yurii Torbyk
committed
MAGETWO-35561: Stabilize story
1 parent b99abf7 commit 8046ec9

File tree

10 files changed

+26
-18
lines changed

10 files changed

+26
-18
lines changed

app/code/Magento/Payment/Test/Unit/Block/Info/CcTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function testGetCcExpDate($ccExpMonth, $ccExpYear)
157157
public function getCcExpDateDataProvider()
158158
{
159159
return [
160-
[3, 2015],
160+
[2, 2015],
161161
[12, 2011],
162162
[01, 2036]
163163
];

dev/tests/integration/framework/Magento/TestFramework/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function initialize($overriddenParams = [])
331331
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure(
332332
$objectManager->get('Magento\Framework\ObjectManager\DynamicConfigInterface')->getConfiguration()
333333
);
334-
\Magento\Framework\Phrase::setRenderer($objectManager->get('Magento\Framework\Phrase\RendererInterface'));
334+
\Magento\Framework\Phrase::setRenderer($objectManager->get('Magento\Framework\Phrase\Renderer\Placeholder'));
335335
}
336336

337337
/**

dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getRealMemoryUsage()
5050
// try to use the Windows command line
5151
// some ports of Unix commands on Windows, such as MinGW, have limited capabilities and cannot be used
5252
$result = $this->_getWinProcessMemoryUsage($pid);
53-
} catch (\Exception $e) {
53+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
5454
// fall back to the Unix command line
5555
$result = $this->_getUnixProcessMemoryUsage($pid);
5656
}

dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function _findMissingClasses($file, $classReflection, $methodName, $en
4949
if (class_exists($missingClassName)) {
5050
continue;
5151
}
52-
} catch (\Exception $e) {
52+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
5353
}
5454
$sourceClassName = $this->getSourceClassName($missingClassName, $entityType);
5555
if (!class_exists($sourceClassName) && !interface_exists($sourceClassName)) {

dev/tools/Magento/Tools/Di/Code/Scanner/XmlScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function _filterEntities(array $output)
6868
$isClassExists = false;
6969
try {
7070
$isClassExists = class_exists($className);
71-
} catch (\Exception $e) {
71+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
7272
}
7373
if (false === $isClassExists) {
7474
if (class_exists($entityName) || interface_exists($entityName)) {

lib/internal/Magento/Framework/Code/Generator.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getGeneratedEntities()
6969
*
7070
* @param string $className
7171
* @return string
72-
* @throws \Exception
72+
* @throws \Magento\Framework\Exception\LocalizedException
7373
* @throws \InvalidArgumentException
7474
*/
7575
public function generateClass($className)
@@ -102,7 +102,9 @@ public function generateClass($className)
102102
$this->tryToLoadSourceClass($className, $generator);
103103
if (!($file = $generator->generate())) {
104104
$errors = $generator->getErrors();
105-
throw new \Exception(implode(' ', $errors));
105+
throw new \Magento\Framework\Exception\LocalizedException(
106+
new \Magento\Framework\Phrase(implode(' ', $errors))
107+
);
106108
}
107109
$this->includeFile($file);
108110
return self::GENERATION_SUCCESS;
@@ -167,15 +169,18 @@ public function getObjectManager()
167169
* @param string $className
168170
* @param \Magento\Framework\Code\Generator\EntityAbstract $generator
169171
* @return void
170-
* @throws \Exception
172+
* @throws \Magento\Framework\Exception\LocalizedException
171173
*/
172174
protected function tryToLoadSourceClass($className, $generator)
173175
{
174176
$sourceClassName = $generator->getSourceClassName();
175177
if (!$this->definedClasses->classLoadable($sourceClassName)) {
176178
if ($this->generateClass($sourceClassName) !== self::GENERATION_SUCCESS) {
177-
throw new \Exception(
178-
sprintf('Source class "%s" for "%s" generation does not exist.', $sourceClassName, $className)
179+
throw new \Magento\Framework\Exception\LocalizedException(
180+
new \Magento\Framework\Phrase(
181+
'Source class "%1" for "%2" generation does not exist.',
182+
[$sourceClassName, $className]
183+
)
179184
);
180185
}
181186
}

lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testGetGeneratedEntities()
6060
}
6161

6262
/**
63-
* @expectedException \Exception
63+
* @expectedException \Magento\Framework\Exception\LocalizedException
6464
* @dataProvider generateValidClassDataProvider
6565
*/
6666
public function testGenerateClass($className, $entityType)
@@ -117,7 +117,7 @@ public function testGenerateClassWithWrongName()
117117
}
118118

119119
/**
120-
* @expectedException \Exception
120+
* @expectedException \Magento\Framework\Exception\LocalizedException
121121
*/
122122
public function testGenerateClassWithError()
123123
{

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getParentsDataProvider()
4242

4343
/**
4444
* @param $entity
45-
* @expectedException \Exception
45+
* @expectedException \Magento\Framework\Exception\LocalizedException
4646
* @dataProvider nonExistentGeneratorsDataProvider
4747
*/
4848
public function testHasIfNonExists($entity)

lib/internal/Magento/Framework/Shell.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(
4242
* @param string $command Command with optional argument markers '%s'
4343
* @param string[] $arguments Argument values to substitute markers with
4444
* @return string Output of an executed command
45-
* @throws \Exception If a command returns non-zero exit code
45+
* @throws \Magento\Framework\Exception\LocalizedException If a command returns non-zero exit code
4646
*/
4747
public function execute($command, array $arguments = [])
4848
{
@@ -51,15 +51,18 @@ public function execute($command, array $arguments = [])
5151

5252
$disabled = explode(',', ini_get('disable_functions'));
5353
if (in_array('exec', $disabled)) {
54-
throw new \Exception("exec function is disabled.");
54+
throw new Exception\LocalizedException(new \Magento\Framework\Phrase("exec function is disabled."));
5555
}
5656

5757
exec($command, $output, $exitCode);
5858
$output = implode(PHP_EOL, $output);
5959
$this->log($output);
6060
if ($exitCode) {
6161
$commandError = new \Exception($output, $exitCode);
62-
throw new \Exception("Command returned non-zero exit code:\n`{$command}`", 0, $commandError);
62+
throw new Exception\LocalizedException(
63+
new \Magento\Framework\Phrase("Command returned non-zero exit code:\n`%1`", [$command]),
64+
$commandError
65+
);
6366
}
6467
return $output;
6568
}

lib/internal/Magento/Framework/Test/Unit/ShellTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function executeDataProvider()
111111
}
112112

113113
/**
114-
* @expectedException \Exception
114+
* @expectedException \Magento\Framework\Exception\LocalizedException
115115
* @expectedExceptionMessage Command returned non-zero exit code:
116116
* @expectedExceptionCode 0
117117
*/
@@ -133,7 +133,7 @@ public function testExecuteFailureDetails($command, $commandArgs, $expectedError
133133
/* Force command to return non-zero exit code */
134134
$commandArgs[count($commandArgs) - 1] .= ' exit(42);';
135135
$this->testExecute($command, $commandArgs, ''); // no result is expected in a case of a command failure
136-
} catch (\Exception $e) {
136+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
137137
$this->assertInstanceOf('Exception', $e->getPrevious());
138138
$this->assertEquals($expectedError, $e->getPrevious()->getMessage());
139139
$this->assertEquals(42, $e->getPrevious()->getCode());

0 commit comments

Comments
 (0)