mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
MINOR Add unit test for MetaComponents
This commit is contained in:
parent
e20be9293f
commit
ed0680a264
@ -1380,7 +1380,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
|
||||
$tags['title'] = [
|
||||
'tag' => 'title',
|
||||
'attributes' => [],
|
||||
'content' => $this->obj('Title')->forTemplate()
|
||||
];
|
||||
|
||||
@ -1442,7 +1441,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
{
|
||||
$tags = [];
|
||||
$tagsArray = $this->MetaComponents();
|
||||
if (!$includeTitle) {
|
||||
if (!$includeTitle || strtolower($includeTitle) == 'false') {
|
||||
unset($tagsArray['title']);
|
||||
}
|
||||
|
||||
|
@ -1353,6 +1353,57 @@ class SiteTreeTest extends SapphireTest
|
||||
// Test without title
|
||||
$meta = $page->MetaTags(false);
|
||||
$this->assertNotContains('<title>', $meta);
|
||||
|
||||
$meta = $page->MetaTags('false');
|
||||
$this->assertNotContains('<title>', $meta);
|
||||
}
|
||||
|
||||
public function testMetaComponents()
|
||||
{
|
||||
$this->logInWithPermission('ADMIN');
|
||||
/** @var SiteTree $page */
|
||||
$page = $this->objFromFixture('Page', 'metapage');
|
||||
|
||||
$charset = Config::inst()->get(ContentNegotiator::class, 'encoding');
|
||||
|
||||
$expected = [
|
||||
'title' => [
|
||||
'tag' => 'title',
|
||||
'content' => "HTML & XML",
|
||||
],
|
||||
'generator' => [
|
||||
'attributes' => [
|
||||
'name' => 'generator',
|
||||
'content' => Config::inst()->get(SiteTree::class, 'meta_generator')
|
||||
],
|
||||
],
|
||||
'contentType' => [
|
||||
'attributes' => [
|
||||
'http-equiv' => 'Content-Type',
|
||||
'content' => "text/html; charset=$charset",
|
||||
],
|
||||
],
|
||||
'description' => [
|
||||
'attributes' => [
|
||||
'name' => 'description',
|
||||
'content' => 'The <br /> and <br> tags'
|
||||
]
|
||||
],
|
||||
'pageId' => [
|
||||
'attributes' => [
|
||||
'name' => 'x-page-id',
|
||||
'content' => $page->ID
|
||||
],
|
||||
],
|
||||
'cmsEditLink' => [
|
||||
'attributes' => [
|
||||
'name' => 'x-cms-edit-link',
|
||||
'content' => $page->CMSEditLink()
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $page->MetaComponents());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user