File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
lib/internal/Magento/Framework Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,11 @@ public function render()
103
103
*/
104
104
public function __toString ()
105
105
{
106
- return $ this ->render ();
106
+ try {
107
+ return $ this ->render ();
108
+ } catch (\Exception $ e ) {
109
+ return $ this ->getText ();
110
+ }
107
111
}
108
112
109
113
/**
Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \Framework \Test \Unit ;
7
7
8
- use \ Magento \Framework \Phrase ;
8
+ use Magento \Framework \Phrase ;
9
9
10
10
class PhraseTest extends \PHPUnit_Framework_TestCase
11
11
{
@@ -124,4 +124,17 @@ public function testGetArguments()
124
124
$ this ->assertEquals ([], $ phrase1 ->getArguments ());
125
125
$ this ->assertEquals ($ arguments , $ phrase2 ->getArguments ());
126
126
}
127
+
128
+ public function testToStringWithExceptionOnRender ()
129
+ {
130
+ $ text = 'raw text ' ;
131
+ $ exception = new \Exception ('something went wrong ' );
132
+ $ phrase = new Phrase ($ text );
133
+
134
+ $ this ->rendererMock ->expects ($ this ->any ())
135
+ ->method ('render ' )
136
+ ->willThrowException ($ exception );
137
+
138
+ $ this ->assertEquals ($ text , (string )$ phrase );
139
+ }
127
140
}
You can’t perform that action at this time.
0 commit comments