Skip to content

Commit 06412dc

Browse files
author
Martijn Swinkels
committed
Moved string withing catch block, and added unit test scenario
1 parent d6cba47 commit 06412dc

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,10 @@ public function filter($value)
10861086
if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
10871087
$value = sprintf(__('Error filtering template: %s'), $e->getMessage());
10881088
} else {
1089-
$value = __("We're sorry, an error has occurred while generating this content.");
1089+
$value = (string) __("We're sorry, an error has occurred while generating this content.");
10901090
}
10911091
$this->_logger->critical($e);
10921092
}
1093-
return (string) $value;
1093+
return $value;
10941094
}
10951095
}

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ protected function getModel($mockedMethods = null)
271271
->getMock();
272272
}
273273

274+
/**
275+
* Test exception handling of filter method
276+
*/
277+
public function testFilterExceptionHandler()
278+
{
279+
$filter = $this->getModel();
280+
$filteredValue = $filter->filter(null);
281+
$this->assertInternalType('string', $filteredValue);
282+
}
283+
274284
/**
275285
* Test basic usages of applyInlineCss
276286
*

0 commit comments

Comments
 (0)