function testToHtml() { $href = new Href(['/foo/bar', 'foo/bar', 'http://example.org/bar']); $html = new HtmlOutputHelper('/base/', []); $expected = '<a href="/foo/bar">/foo/bar</a><br />' . '<a href="/base/foo/bar">/base/foo/bar</a><br />' . '<a href="http://example.org/bar">http://example.org/bar</a>'; $this->assertEquals($expected, $href->toHtml($html)); }
/** * Generate html representation for this value. * * The html output is 100% trusted, and no effort is being made to sanitize * it. It's up to the implementor to sanitize user provided values. * * The output must be in UTF-8. * * The baseUri parameter is a url to the root of the application, and can * be used to construct local links. * * @param HtmlOutputHelper $html * @return string */ function toHtml(HtmlOutputHelper $html) { switch ($this->type) { case self::UNAUTHENTICATED: return '<em>unauthenticated</em>'; case self::AUTHENTICATED: return '<em>authenticated</em>'; case self::HREF: return parent::toHtml($html); case self::ALL: return '<em>all</em>'; } }