commit
9af2030538
2 files changed
+31
-1
No files matched your search
@@ -399,4 +399,21 @@ class HtmlBuilder {
|
|||||||
return $safe;
|
return $safe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a meta tag.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $content
|
||||||
|
* @param array $attributes
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function meta($name, $content, array $attributes = [])
|
||||||
|
{
|
||||||
|
$defaults = compact('name', 'content');
|
||||||
|
|
||||||
|
$attributes = array_merge($defaults, $attributes);
|
||||||
|
|
||||||
|
return '<meta'.$this->attributes($attributes).'>'.PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->htmlBuilder = new HtmlBuilder($this->urlGenerator);
|
$this->htmlBuilder = new HtmlBuilder($this->urlGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the test environment.
|
* Destroy the test environment.
|
||||||
*/
|
*/
|
||||||
@@ -42,4 +41,18 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals('<dl class="example"><dt>foo</dt><dd>bar</dd><dt>bing</dt><dd>baz</dd></dl>', $result);
|
$this->assertEquals('<dl class="example"><dt>foo</dt><dd>bar</dd><dt>bing</dt><dd>baz</dd></dl>', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMeta()
|
||||||
|
{
|
||||||
|
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
|
||||||
|
|
||||||
|
$this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">'.PHP_EOL, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMetaOpenGraph()
|
||||||
|
{
|
||||||
|
$result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']);
|
||||||
|
|
||||||
|
$this->assertEquals('<meta content="website" property="og:type">'.PHP_EOL, $result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user