예제 #1
0
 public function testThatToStringIsAliasToRender()
 {
     $text = 'some text';
     $arguments = ['arg1', 'arg2'];
     $result = 'rendered text';
     $this->phrase = new \Magento\Framework\Phrase($text, $arguments);
     $this->renderer->expects($this->once())->method('render')->with([$text], $arguments)->will($this->returnValue($result));
     $this->assertEquals($result, (string) $this->phrase);
 }
예제 #2
0
 /**
  * Test that to string is alias to render
  *
  * @return void
  */
 public function testThatToStringIsAliasToRender()
 {
     $text = 'some text';
     $arguments = ['arg1', 'arg2'];
     $result = 'rendered text';
     $phrase = new Phrase($text, $arguments);
     Phrase::setRenderer($this->rendererMock);
     $this->rendererMock->expects($this->once())->method('render')->with([$text], $arguments)->willReturn($result);
     $this->assertEquals($result, (string) $phrase);
 }
예제 #3
0
 public function testToStringWithExceptionOnRender()
 {
     $text = 'raw text';
     $exception = new \Exception('something went wrong');
     $phrase = new Phrase($text);
     $this->rendererMock->expects($this->any())->method('render')->willThrowException($exception);
     $this->assertEquals($text, (string) $phrase);
 }
예제 #4
0
 /**
  * Render phrase
  *
  * @return string
  */
 public function render()
 {
     return self::$_renderer ? self::$_renderer->render([$this->_text], $this->_arguments) : $this->_text;
 }