asUrl() public method

Formats the value as a hyperlink.
public asUrl ( mixed $value, array $options = [] ) : string
$value mixed the value to be formatted.
$options array the tag options in terms of name-value pairs. See [[Html::a()]].
return string the formatted result.
Exemplo n.º 1
0
 public function testAsUrl()
 {
     $value = 'http://www.yiiframework.com/';
     $this->assertSame("<a href=\"{$value}\">{$value}</a>", $this->formatter->asUrl($value));
     $value = 'https://www.yiiframework.com/';
     $this->assertSame("<a href=\"{$value}\">{$value}</a>", $this->formatter->asUrl($value));
     $value = 'www.yiiframework.com/';
     $this->assertSame("<a href=\"http://{$value}\">{$value}</a>", $this->formatter->asUrl($value));
     $value = 'https://www.yiiframework.com/?name=test&value=5"';
     $this->assertSame("<a href=\"https://www.yiiframework.com/?name=test&amp;value=5&quot;\">https://www.yiiframework.com/?name=test&amp;value=5&quot;</a>", $this->formatter->asUrl($value));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asUrl(null));
 }